#include <bits/stdc++.h>
using namespace std;

int n, k;

void solve(){
    cin >> n >> k;

    int cnt = 1;

    int query = 0;

    for(int i = 0; i < n; i++){
        if(i) query = i ^ (i - 1);
        cout << query << endl;
        int r;
        cin >> r;
        if(r == 1) return;
    }
}

int main(){
    // freopen("inp.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    int t;
    cin >> t;
    while(t--) solve();
}