/************************************************************** User: error408 Language: C/C++ School: SSDUT Saying: Do one thing at a time,and do well. ****************************************************************/ #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define clr(s,x) memset((s),(x),sizeof(s)) #define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 #define lowbit(x) (x&(-x)) #define PB push_back #define For(i,a,b) for(int i=a;i vint; typedef vector vstring; /************************************END DEFINE*********************************************/ LL mul(LL a,LL b,LL mod){ LL n = 0; while(b){ if(b&1) n = (n+a)%mod; a = (a*2)%mod; b /= 2; } return n; } int main() { int t; cin>>t; while(t--){ LL q,p; cin>>q>>p; cout<