#include <bits/stdc++.h>
using namespace std;
int n;
int main(){
	int i,all = 1;
	cin >> n;
	while (all < n) all <<= 1;
	all -= 1;
	for (i = 0; i < n; ++i){
		int lc = all&(i<<1),rc = all&(i<<1|1);
		if (lc >= n) lc -= (all+1)>>1;
		if (rc >= n) rc -= (all+1)>>1;
		++lc,++rc;
		cout << lc << ' ' << rc << '\n'; 
	}
	return 0;
}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;

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

int main(){
  int t;
  cin>>t;
  
  while(t--){
    int n;
    string s1,s2,s3;
    cin>>n>>s1>>s2>>s3;
    
    rep(i,n) cout<<0;
    rep(i,n) cout<<1;
    cout<<0<<endl;
  }
  
  return 0;
}