#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int a, N, M;
	cin >> a;
	int brojac = 0;
	for (int q = 0; q < a; q++) {
		cin >> N >> M;
		if (N != M) {cout << -1<<endl; continue; }
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				if (j == 0 || i == 0 || N - i <= j) cout << 1;
				else cout << 0;
			}
			cout << endl;
		}
	}
	return 0;
}