#include<bits/stdc++.h>
using namespace std;
int main() 
{
int n;
cin >> n;
int N;
int M;
int A[N][M];
int s1 = 0;
int s2 = 0;
int g = 0;
for (int z = 0; z < n; z++)
{
	cin >> N >> M;
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < M; j++)
		{
			if (A[i][j] % 2 == 0)
			{
				A[i][j] = 1;
			}
			else
			{
				A[i][j] = 0;
			}
		}
	}
}
for (int i = 0; i < N; i++)
{
	for (int j = 0; j < M; j++)
	{
		s2 = s2 + A[g][j];
		s1 = s1 + A[i][g];
		if (s1 % i != 0)
		{
		cout << -1;
		}
		else if (s2 % j != 0)
		{
		cout << -1;
		}
		else if (s1 % i == 0 && s2 % j == 0)
		{
		cout << A[i][j];
		}
		g++;
	}
}	
return 0;
}