#include<bits/stdc++.h>
#include<bits/stdc++.h>
#define no if(1){cout << "No\n"; return;}
#define yes if(1){cout << "Yes\n"; return;}
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define For(i, n) for(int i = 0; i < n; i++)
#define FoR(i, j, n) for(int i = j; i < n; i++)
#define all(a) a.begin(), a.end()
//#define endl '\n'
#define pi 3.14159265359
#define pii pair<int, int>
#define x first
#define y second
#define mid(l, r) (l + r) / 2
#define ld long double
#define afterdot(x) fixed << setprecision(x)
#define pdd pair<ld, ld>


using namespace std;


void solve(){
    int n, k, a;
    cin >> n>> k;
    For(i, n){
        cout << (i ^ max(0ll, i - 1)) << endl;
        cin >> a;
        if(a == 1)break;
    }
}

signed main(){
    //ios
    int t = 1;
    cin >> t;
    while(t--){
        solve();
    }
}


