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

void NacrtajMatricu(int n) {
    for (int i = 1; i < n + 1; i++) {
        if (i == 1 || i == n) for (int i = 0; i < n; i++) cout << 1;
        else {
            cout << 1;
            for (int j = 0; j < n - i; j++) {
                cout << 0;
            }
            for (int j = 0; j < i - 1; j++) {
                cout << 1;
            }
        }
        cout << endl;
    }
}

int main() {
    int T;
    cin >> T;

    vector<pair<int, int>> matrice(T);
    vector<int> resenja(T);

    for (int i = 0; i < T; i++) {
        cin >> matrice[i].first;
        cin >> matrice[i].second;

        int check = matrice[i].first - matrice[i].second;
        if (check == 0) resenja[i] = matrice[i].first;
        else resenja[i] = -1;
    }

    for (int i = 0; i < T; i++) {
        if (resenja[i] == -1) cout << -1 << endl;
        else {
            NacrtajMatricu(resenja[i]);
        }
    }
}