#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int main(){
	
	int t;
	cin >> t;
	
	vector<int> n(t);
	vector<int> m(t);
	
	for(int p = 0; p < t; p++){
		cin >> n[p];
		cin >> m[p];
	}
	
	bool found = false;
	
	for(int p = 0; p < t; p++){
		
		if(n[p] != m[p]){
			cout << "-1" << endl;
		}
		
		else{
			
			vector<vector<int>> matrica[n[p]][m[p]];
			
			for(int i = 0; i < n[p]; i++){
				for(int j = 0; j < m[p]; j++){
					int si = 0;
					int sj = 0;
					
					if(n[p] == 4){
						if(i == 2 && j == 2){
							cout << "0" << " ";
						}
						else cout << "1" << " ";	
							
					}
					
					
					
					
				}
				cout << endl;
			}
		}
	}
	
	
	
	
	return 0;
}