﻿/* Author : Vivek Hamirwasia Solution for problem code FGFS. ============================================== A programmer started to cuss, 'cause getting to sleep was a fuss. As he lay there awake in his bed, Looping around and 'round in his head, Was: while(!asleep()) sheep++; ============================================== */ #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define CLR(a,x) memset(a,x,sizeof(a)) #define PB push_back #define INF 1000000000 #define MOD 1000000007 #define MP make_pair #define tr(container , it) for(typeof(container.begin()) it=container.begin() ; it!=container.end() ; it++) #define FOR(i,a,b) for(i=a;i #define PII pair < int , int > #define MAX 1000000000 vector V[1000005]; map my; int max_act_sel(vector acts) { int sz = acts.size(); if(sz==0) return 0; sort(acts.begin(), acts.end()); int ans = 1; int lst = acts[0].first; for(int i=1;i=lst) { ans++; lst = acts[i].first; } } return ans; } int main() { int t; scanf("%d",&t); while(t--) { my.clear(); int pos = 0; int n, k; scanf("%d%d",&n,&k); if(n==0) { printf("0\n"); continue; } for(int i=0;i<=n;i++) V[i].clear(); int s,f,p; for(int i=0;i