void push(int x) {
if (a.empty() && b.empty()) {
a.push(x);
return;
}
if (a.empty()) {
a.push(x);
while (!b.empty()) {
a.push(b.front());
b.pop();
}
}
else {
b.push(x);
while (!a.empty()) {
b.push(a.front());
a.pop();
}
}
}
int pop() {
if (a.empty()) {
int temp = b.front();
b.pop();
return temp;
}
else {
int temp = a.front();
a.pop();
return temp;
}
}