#include #include using namespace std; using namespace atcoder; using ll=long long; vector>> v={{{0,0},{1,0},{2,0},{2,1}},{{0,1},{1,1},{0,2},{0,3}},{{2,2},{1,2},{1,3},{1,4}},{{2,3},{2,4},{2,5},{1,5}},{{0,4},{0,5},{0,6},{1,6}},{{0,7},{1,7},{2,7},{2,6}}}; int main() { int t; cin>>t; while(t--){ int n,m; cin>>n>>m; if(n==1||m==1||(n*m)%8!=0){ cout<<-1<> ans(n,vector(m)); if(n%2!=0){ int cnt=1; for(int i=0;i