#include #include using namespace std; int mp[1010][1010]; int main(){ int t; cin >> t; while(t){ t--; int i,j,n,m; cin >> n >> m; if(n==1 && m==1){ cout << 0 << endl; cout << 1 << " " << 1 << endl; }else if(n&1 || m&1){ cout << -1 << endl; }else{ vector> v; for(j=0;j0;i-=2){ v.push_back({i,j + 1}); v.push_back({i - 1,j}); v.push_back({i,j}); v.push_back({i - 1,j + 1}); } }else{ for(i=0;i