#include <bits/stdc++.h>

using namespace std;

int main()
{
    int T, M, N; vector<int> v1, v2;
    cin >> T;
    for (int i = 0; i < T; i++) {
        cin >> N >> M;
        v1.push_back(N);
        v2.push_back(M);
    }
    for (int i = 0; i < v1.size(); i++) {
        N = v1[i];
        M = v2[i];
        if (N != M) {
            cout << -1 << '\n';
        }
        else {
            for (int i = 1; i <= M; i++) {
                for (int j = 1; j <= N - i; j++) {
                    cout << 0 << " ";
                }
                for (int j = 1; j <= i; j++) {
                    cout << 1 << " ";
                }
                cout << '\n';
            }
        }
    }
}