#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll t;
main(){
    cin>>t;
    while(t--){
        ll n,m;
        cin>>n>>m;
     if(n==m){
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(i+j<=m)cout<<0<<' ';
            else cout<<1<<' ';
        }
        cout<<endl;
    }
}
else cout<<-1<<endl;
    }
}