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