#include #include #include #include #include using namespace std; const int maxn=50010; priority_queue,greater >q[2]; int a[maxn],b[maxn],c[maxn]; void work(){ while(!q[0].empty())q[0].pop(); while(!q[1].empty())q[1].pop(); int n,m; scanf("%d%d",&n,&m); for(int i=1; i<=n; ++i) scanf("%d%d",&a[i],&b[i]); for(int i=0; i