#include<bits/stdc++.h>

using namespace std;

int main() {
//ios_base()::sync_with_stdio(false);
cin.tie(0);
int t,n,m;
cin>>t;
vector<pair<int,int> >br(t);
for(int i=0;i<t;i++){
		cin>>n>>m;
		br[i]=make_pair(n,m);
}
for(int i=0;i<t;i++){

	if(br[i].first!=br[i].second)cout<<-1<<endl;
	else {
		for(int a=0;a<br[i].first;a++){
	
			for(int c=0;c<br[i].first;c++){
				if(c>br[i].first-a-2)cout<<1<<" ";
				else cout<<0<<" ";
			}
			cout<<endl;
		}
	}
	
	
	
}



}