#include #include #include using namespace std; using ll = long long; void Print(vector>& ans){ int n=ans.size(), m=ans[0].size(); for(int i=0; i r, vector c){ vector p(n); for(int i=0; i(n, -1)); for(int i=0; i> n; vector r(n), c(n); for(auto&x:r) cin >> x; for(auto&x:c) cin >> x; if(n<=2){ cout << (n==1?1:-1) << endl; return; } if(n<=4){ naive(n, r, c); return; } vector ans(n, vector(n, -1)); for(int i=0; i> t; while(t--) solve(); return 0; }