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

int main()
{
    iostream::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int t;
    cin >> t;
    while(t--) {
        int n, m;
        cin >> n >> m;
        if (n != m) {
            cout << "-1\n";
            continue;
        }
        vector<int> temp(n, 1);
        vector<vector<int>> a(m, temp);

        for (int i = 1; i < n - 1; i++) {
            for (int j = 1; j < n - i; j++) {
                a[i][j] = 0;
            }
        }
        for (auto x : a) {
            for (int y : x) cout << y;
            cout << "\n";
        }

    }


    return 0;
}