class MyQueue {
Stack<Integer> inStack, outStack;
public MyQueue() {
this.inStack = new Stack<>();
this.outStack = new Stack<>();
}
public void push(int x) {
this.inStack.push(x);
}
public int pop() {
if (this.outStack.size() == 0) {
while (this.inStack.size() != 0) {
this.outStack.push(this.inStack.pop());
}
}
return this.outStack.pop();
}
public int peek() {
if (this.outStack.size() == 0) {
while (this.inStack.size() != 0) {
this.outStack.push(this.inStack.pop());
}
}
return this.outStack.peek();
}
public boolean empty() {
return this.outStack.size() == 0 && this.inStack.size() == 0;
}
}