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

int main(){

int t, n, m;
cin>>t;

for (int k=0; k<t; k++){
	cin>>n>>m;
	if (n!=m) cout<<"-1";
	else {
		int matrica[n][m];
		for (int i=1; i<=n; i++){
			for (int j=1; j<=m; j++){
				if (j>=m-i+1) matrica[i][j]=1;
				else matrica[i][j]=0;
				
				
			}
		}
	for (int i=1; i<=n; i++){
		for (int j=1; j<=m; j++){
			cout<<matrica[i][j]<<" ";
		}
		cout<<endl;
	}
	}


}



return 0;
}