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

#define ll long long
#define Rip_classic_loki_for_glorious_purpose ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

// need for speed

int main()
{
    Rip_classic_loki_for_glorious_purpose;  
    int t;
    cin >> t;

    while(t--){

    	int n,k,check;
    	cin >> n >> k;

		int w = 0;
		for(int i = 0;i < n;i++){
			cout << (i ^ w) << endl;
			cin >> check;
			if(check == 1){
				break;
			}
			w = i;
		}
    }
    return 0;
}
