#include<bits/stdc++.h>

using namespace std;
int t,n,m,br1,br0;
int main(){
  cin >> t;
  while(t--){
    cin >> n >> m;
    if(n!=m){
      cout<<-1<<endl;
      continue;
    }
    else{
      for(int i=1; i<=n; i++){
          br0=n-i;
          if(i==1){
            br1=n-1;
            br0=0;
          }
          else if(i==n){
            br1=n-1;
            br0=0;
          }
          else br1=i-1;

          cout<<1<<" ";
        for(int j=1; j<=br0; j++){
          cout<<0<<" ";
        }
        for(int k=1; k<=br1; k++){
          cout<<1<<" ";
        }
        cout<<endl;
      }
    }
  }

  return 0;
}