#include <iostream>
void send(bool in[], bool out[], int N, int B)
{
for(int i = 0; i < N; i++)
std::cout << in[i];
std::cout << std::endl;
char c;
for(int i = 0; i < N-B; i++)
{
std::cin >> c;
out[i] = (c=='1');
}
}
int main()
{
int T;
std::cin >> T;
while(T--)
{
int N, B, F;
std::cin >> N >> B >> F;
int set[N-B];
for(int i = 0; i < N-B; i++)
set[i] = 0;
bool in[N];
bool out[N-B];
for(int k = 0; k < 4; k++)
{
for(int i = 0; i < N; i++)
in[i] = i&(1 << k);
send(in, out, N, B);
for(int i = 0; i < N-B; i++)
set[i] += out[i]*(1 << k);
}
bool status[N];
for(int i = 0; i < N; i++)
status[i] = false;
int pre = 0;
int last = -1;
for(int i = 0; i < N-B; i++)
{
if(set[i] <= last)
pre += 16;
status[pre + set[i]] = true;
last = set[i];
}
for(int i = 0; i < N; i++)
if(!status[i])
std::cout << i << " ";
std::cout << std::endl;
std::cin >> pre;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdm9pZCBzZW5kKGJvb2wgaW5bXSwgYm9vbCBvdXRbXSwgaW50IE4sIGludCBCKQp7Cglmb3IoaW50IGkgPSAwOyBpIDwgTjsgaSsrKQoJCXN0ZDo6Y291dCA8PCBpbltpXTsKCXN0ZDo6Y291dCA8PCBzdGQ6OmVuZGw7CgljaGFyIGM7Cglmb3IoaW50IGkgPSAwOyBpIDwgTi1COyBpKyspCgl7CgkJc3RkOjpjaW4gPj4gYzsKCQlvdXRbaV0gPSAoYz09JzEnKTsKCX0KfQoKaW50IG1haW4oKQp7CglpbnQgVDsKCXN0ZDo6Y2luID4+IFQ7CgkKCXdoaWxlKFQtLSkKCXsKCQlpbnQgTiwgQiwgRjsKCQlzdGQ6OmNpbiA+PiBOID4+IEIgPj4gRjsKCQkKCQlpbnQgc2V0W04tQl07CgkJZm9yKGludCBpID0gMDsgaSA8IE4tQjsgaSsrKQoJCQlzZXRbaV0gPSAwOwoJCQoJCWJvb2wgaW5bTl07CgkJYm9vbCB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