#include using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; while(T--){ int N,M; cin >> N >> M; if(N%2 || M%2 || (N%4 && M%4)){cout << "-1\n"; continue;} bool swapped = false; if(N%4) swap(N,M),swapped = true; vector> answer(N,vector(M)); int idx = 1; for(int i=0; i> answer2(M,vector(N)); for(int i=0; i