#include #include #include #include #include #include #include #include //#include using namespace std; #define FOR(i, n, m) for(int i = n; i <= m; i++) #define REP(i, n, m) for(int i = n; i >= m; i--) #define PB push_back #define MP make_pair typedef long long ll; typedef unsigned long long ull; typedef pair PII; typedef pair PLI; const int maxn = 200010; const int maxm = 100010; ll mul(ll a,ll k,ll mod){ ll n = 0; while(k){ if(k&1) n = (n+a)%mod; a = (a << 1) % mod; k >>= 1; } return n; } int main(){ int t; cin>>t; ll q, p; while(t--){ cin>>q>>p; cout<