#include #include int gcd(int m,int n) { int temp; while(n) { temp=m%n; m=n; n=temp; } return m; } int main() { int T; scanf("%d",&T); while(T--) { int arr[1005]; int N,Q; int aL[1005],aR[1005],ans; int L,R; int ques[1005]; int pointer=1; bool flag; scanf("%d%d",&N,&Q); for(int i=1;i<=N;i++) arr[i]=1; for(int j=0;j