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

using ll = long long;
using vi = vector<int>;
#define pb push_back
#define eb emplace_back
#define f  first
#define s  second

void solve() {
	int n, k;
	cin >> n >> k;
	int r;
	for (int i = 0; i < n; ++i) {
		cout << (i ^ max(0, i-1)) << endl;
		cin >> r;
		if (r != 0) return;
	}
}

int main() {
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);

	int T;
	cin >> T;
	while (T--)
		solve();
	
	return 0;
}
