func_code_string: #include<bits/stdc++.h>   #define fi first   #define se second         #define all(x) (x).begin(), (x).end()   #define rall(x) (x).rbegin(), (x).rend()   #define pb push_back   #define len(x) (int)(x).size()   typedef long long ll;   typedef long double ld;   using namespace std;      const int N = 1001;   const int mod = 998244353;   int g[N][N];   int perm[N][N];   int cnt[N][N];   int n;   void add(int id, int val){       for(int x = 0; x < n; ++x){           cnt[x][perm[id][x]] += val;       }   }   void md(int &a){       if(a >= mod)           a-=mod;   }   void solve(){       cin >> n;       for(int i = 0;  i < 2*n; ++i){           for(int j = 0 ; j < n; ++j){               cin >> perm[i][j];           }           add(i , +1);       }       vector < bool > active(2*n, 1);       int ans = 1;       vector < int > answer;       while(true){           bool have = 0;           for(int x = 0; x < 2*n; ++x)               if(active[x])have = 1;           if(!have)               break;           int found = -1;           for(int x = 0 ;x < 2 * n; ++x){               if(active[x]){                   for(int i = 0 ;i  < n; ++i){                       if(cnt[i][perm[x][i]] == 1){                           found = x;                           break;                       }                   }               }           }           if(found == -1){               ans *= 2, md(ans);               for(int x = 0; x < 2*n; ++x)                   if(active[x])                       found = x;              }           answer.pb(found);           /// dell all shit           for(int j = 0; j < 2*n;++j){               if(active[j]){                   bool del = 0;                   for(int z = 0; z < n; ++z){                       if(perm[found][z] == perm[j][z])                           del = 1;                   }                   if(del)                       active[j] = 0, add(j , -1);               }           }       }       cout << ans <<   n ;       for(auto u : answer)           cout << u + 1 <<    ;       cout <<   n ;   }   signed main()   {       ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);       int t;cin >> t;       while(t--){           solve();       }       return 0;   }   