#include #define mann 100005 using namespace std; int dp1[mann],dp2[mann]; int a[mann],b[mann]; int main() { int t,n,m; scanf("%d",&t); while(t--) { int ans,ans1=-1,ans2=-1; int res=-1; memset(dp1,0,sizeof(dp1)); memset(dp2,0,sizeof(dp2)); scanf("%d%d",&n,&m); for(int i=0; i