#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define ll long long
#define ld long double
#define mp make_pair
int main(){
    int t;scanf("%i",&t);
    while(t--){
        int n,m;scanf("%i%i",&n,&m);
        if(n!=m){printf("-1\n");continue;}
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++)printf("%i ",(n+1-i)<=j);
            printf("\n");
        }
    }
    return 0;
}