#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int n,m,t,k;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> t;
    while (t--)
    {
        cin >> n >> k;

        // k = 2

        int prv = 0, r = 0;
        for (int i = 0; i < n; i++)
        {
            cout << (prv^i) << endl;
            prv = i;
            cin >> r;
            if (r == 1) break;
        }
    }



    return 0;
}