#include #include using namespace std; #define N 1010 int main(){ //freopen("in.txt","r",stdin); int T,n,m,ans; scanf("%d",&T); while(T--){ scanf("%d%d",&n,&m); if(n