class MyStack {
public:
queue<int> q;/** Initialize your data structure here. */MyStack(){}/** Push element x onto stack. */voidpush(int x){
q.push(x);}/** Removes the element on top of the stack and returns that element. */intpop(){int size=q.size()-1;for(int i=0;i<size;i++){int data=q.front();
q.pop();
q.push(data);}int d=q.front();
q.pop();return d;}/** Get the top element. */inttop(){int size=q.size()-1;for(int i=0;i<size;i++){int data=q.front();
q.pop();
q.push(data);}int d=q.front();
q.pop();
q.push(d);return d;}/** Returns whether the stack is empty. */
bool empty(){return q.empty();}};
class MyQueue {
public:
stack<int> left;
stack<int> right;/** Initialize your data structure here. */MyQueue(){}/** Push element x to the back of queue. */voidpush(int x){
right.push(x);}/** Removes the element from in front of queue and returns that element. */intpop(){if(left.empty()){int size=right.size();for(int i=0;i<size;i++){int d=right.top();
right.pop();
left.push(d);}}int v=left.top();
left.pop();return v;}/** Get the front element. */intpeek(){if(left.empty()){int size=right.size();for(int i=0;i<size;i++){int d=right.top();
right.pop();
left.push(d);}}int v=left.top();return v;}/** Returns whether the queue is empty. */
bool empty(){return left.empty()&&right.empty();}};