// {{{ Template
#include <bits/stdc++.h>
#ifdef LOCAL
#include "/Library/debug/debug.h"
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
using namespace std;
#define MAX 2e9
#define MIN -2e9
#define MOD 1000000007
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; }
#define INF 1e17
#define PI acos(-1.0)
#define mid(s,e) (s+(e-s)/2)
#define clz(n) __builtin_clzll(n)
#define nbOfBits(n) __builtin_popcountll(n)
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define pb push_back
#define sz(a) ((int)((a).size()))
#define int long long
#define double long double
#define fi first
#define se second
#define getunique(v) {sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());}
// const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
using vi = vector<int>;
using vvi = vector<vi>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using pii = pair<int, int>;
using pdd = pair<double, double>;
using vpii = vector<pii>;
using vpdd = vector<pdd>;
/// }}}
unsigned seed = 0;
int case_4() {
auto bits = string(8,'0');
for(int j=0;j<4;j++) {
bits[j] = '1';
}
int x = 4;
while(1) {
bits = string(8,'0');
for(int j=0;j<4+rand()%2;j++) {
bits[j] = '1';
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
shuffle(all(bits), rng);
cout<<bits<<endl;
cin>>x;
if(x > 4) {
cout<<"11111111"<<endl;
cout << flush;
cin>>x;
}
if(x != 4) {
return x;
}
}
}
int case_3() {
auto bits = string(8,'0');
for(int j=0;j<3;j++) {
bits[j] = '1';
}
int x = 3;
while(1) {
bits = string(8,'0');
for(int j=0;j<3+rand()%2;j++) {
bits[j] = '1';
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
shuffle(all(bits), rng);
cout<<bits<<endl;
cin>>x;
if(x > 4) {
cout<<"11111111"<<endl;
cout << flush;
cin>>x;
}
if(x != 3) {
return x;
}
}
}
int case_2() {
auto bits = string(8,'0');
for(int j=0;j<2;j++) {
bits[j] = '1';
}
int x = 2;
while(1) {
bits = string(8,'0');
for(int j=0;j<2+rand()%2;j++) {
bits[j] = '1';
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
shuffle(all(bits), rng);
cout<<bits<<endl;
cin>>x;
if(x > 4) {
cout<<"11111111"<<endl;
cout << flush;
cin>>x;
}
if(x != 2) {
return x;
}
}
}
int case_1() {
auto bits = string(8,'0');
bits[0] = '1';
int x = 1;
while(1) {
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
shuffle(all(bits), rng);
cout<<bits<<endl;
cin>>x;
if(x > 4) {
cout<<"11111111"<<endl;
cout << flush;
cin>>x;
}
if(x != 1) {
return x;
}
}
}
bool solve() {
string bits(8,'1');
cout<<bits<<endl;
cout << flush;
int x;
cin>>x;
if(x > 4) {
cout<<"11111111"<<endl;
cout << flush;
cin>>x;
}
while(x != 0) {
if(x < 0) {
return 0;
}
if(x == 4) x = case_4();
if(x == 3) x = case_3();
if(x == 2) x = case_2();
if(x == 1) x = case_1();
}
return 1;
}
void preprocessing() {}
bool MULTI_TEST_CASES = 1;
// {{{ Main
int32_t main() {
cout << setprecision(20);
cout<<fixed;
preprocessing();
int t=1;
if(MULTI_TEST_CASES) cin>>t;
for(int i=1;i<=t;i++) {
if(solve() == false) break;
}
return 0;
}
// }}}
Ly8ge3t7IFRlbXBsYXRlCiNpbmNsdWRlIDxiaXRzL3N0ZGMrKy5oPgojaWZkZWYgTE9DQUwKI2luY2x1ZGUgIi9MaWJyYXJ5L2RlYnVnL2RlYnVnLmgiCiNkZWZpbmUgZGVidWcoeC4uLikgY2VyciA8PCAiWyIgPDwgI3ggPDwgIl0gPSBbIjsgX3ByaW50KHgpCiNlbHNlCiNkZWZpbmUgZGVidWcoeC4uLikKI2VuZGlmCgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKI2RlZmluZSBNQVggICAgICAgICAgICAgICAgIDJlOQojZGVmaW5lIE1JTiAgICAgICAgICAgICAgICAgLTJlOQojZGVmaW5lIE1PRAkJCQkJMTAwMDAwMDAwNwojZGVmaW5lIGJ5KHgpCQkJCVtdKGNvbnN0IGF1dG8mIGEsIGNvbnN0IGF1dG8mIGIpIHsgcmV0dXJuIGEueCA8IGIueDsgfQojZGVmaW5lIElORiAgICAgICAgICAgICAgICAgMWUxNwojZGVmaW5lIFBJICAgICAgICAgICAgICAgICAgYWNvcygtMS4wKQojZGVmaW5lIG1pZChzLGUpICAgICAgICAgICAgKHMrKGUtcykvMikKI2RlZmluZSBjbHoobikgICAgICAgICAgICAgIF9fYnVpbHRpbl9jbHpsbChuKQojZGVmaW5lIG5iT2ZCaXRzKG4pICAgICAgICAgX19idWlsdGluX3BvcGNvdW50bGwobikKI2RlZmluZSBhbGwoeCkgICAgICAgICAgICAgICh4KS5iZWdpbigpLCAoeCkuZW5kKCkKI2RlZmluZSBlbmRsICAgICAgICAgICAgICAgICdcbicKI2RlZmluZSBwYiAgICAgICAgICAgICAgICAgIHB1c2hfYmFjawojZGVmaW5lIHN6KGEpICAgICAgICAgICAgICAgKChpbnQpKChhKS5zaXplKCkpKQojZGVmaW5lIGludCAgICAgICAgICAgICAgICAgbG9uZyBsb25nCiNkZWZpbmUgZG91YmxlICAgICAgICAgICAgICBsb25nIGRvdWJsZQojZGVmaW5lIGZpCQkJCQlmaXJzdAojZGVmaW5lIHNlCQkJCQlzZWNvbmQKI2RlZmluZSBnZXR1bmlxdWUodikJCXtzb3J0KHYuYmVnaW4oKSwgdi5lbmQoKSk7IHYuZXJhc2UodW5pcXVlKHYuYmVnaW4oKSwgdi5lbmQoKSksIHYuZW5kKCkpO30KCi8vIGNvbnN0IGludCBkeFs0XSA9IHsxLDAsLTEsMH0sIGR5WzRdID0gezAsMSwwLC0xfTsKdXNpbmcgdmkgPSB2ZWN0b3I8aW50PjsKdXNpbmcgdnZpID0gdmVjdG9yPHZpPjsKdXNpbmcgdmIgPSB2ZWN0b3I8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