func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 100;   int n;   int t[2][N];   vector<int> vals[N];   vector<pair<int, int>> G[N];   bool vis[N];   int color[N];   vector<int> C[2];   bool cycle;   void dfs(int v) {     vis[v] = true;     C[color[v]].push_back(v);     for (auto it : G[v]) {       if (vis[it.first] && (color[v] ^ it.second) != color[it.first])         cycle = true;       if (!vis[it.first]) {         color[it.first] = color[v] ^ it.second;         dfs(it.first);       }     }   }   void solve() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) G[i].clear(), vals[i].clear();     for (int j = 0; j <= 1; ++j)       for (int i = 1; i <= n; ++i) {         scanf( %d , &t[j][i]);         vals[t[j][i]].push_back(i);       }     for (int i = 1; i <= n; ++i) {       if ((int)vals[i].size() != 2) {         printf( -1 n );         return;       }       int u = vals[i][0], v = vals[i][1], w;       if (u == v) continue;       w = ((t[0][u] == t[0][v] && t[0][u] == i) ||            (t[1][u] == t[1][v] && t[1][u] == i));       G[u].push_back(make_pair(v, w));       G[v].push_back(make_pair(u, w));     }     cycle = false;     for (int i = 1; i <= n; ++i) vis[i] = false;     vector<int> ans;     for (int i = 1; i <= n; ++i)       if (!vis[i]) {         for (int j = 0; j <= 1; ++j) C[j].clear();         dfs(i);         if ((int)C[0].size() > (int)C[1].size()) swap(C[0], C[1]);         for (auto it : C[0]) ans.push_back(it);       }     if (cycle) printf( -1 n );     printf( %d n , (int)ans.size());     for (auto it : ans) printf( %d  , it);     printf(  n );   }   int main() {     int T;     scanf( %d , &T);     while (T--) {       solve();     }     return 0;   }   