import java.util.Stack;

public class Solution {
    Stack<Integer> stack1 = new Stack<Integer>();
    Stack<Integer> stack2 = new Stack<Integer>();

    public void push(int node) {
        stack1.push(node);
    }

    public int pop() {
        // 这里从stack2中弹出的时候需要判断stack2是否为空,如果不为空就直接弹出
        // 如果为空,此时才可以从stack1中pop然后push到stack2中,不然顺序会乱
        if(stack2.empty()) {
            while(!stack1.empty()) {
                stack2.push(stack1.pop());
            }
        }
        return stack2.pop();
    }
}