queue<int>q[maxn];
struct Queue
{
priority_queue< int,vector<int>,less<int> >A,B;
void Push( int x ){A.push(x);}
void Pop( int x ){B.push(x);}
int Top()
{
while ( !B.empty()&&A.top()==B.top() )
A.pop(),B.pop();
return A.top();
}
void Clear()
{
while ( !A.empty() )
A.pop();
while ( !B.empty() )
B.pop();
}
}Q[maxn];