func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAXN = 400100;   vector<int> grafo[MAXN];   int a[MAXN], b[MAXN];   pair<int, int> p[MAXN];   int q[MAXN];   bool vis[MAXN];   int n;   vector<int> vec;   void dfs(int x) {     vis[x] = true;     vec.push_back(x);     if (x > n)       vis[x - n] = true;     else       vis[x + n] = true;     for (int i = 0; i < grafo[x].size(); i++) {       int at = grafo[x][i];       if (vis[at] == true) continue;       dfs(at);     }   }   int main() {     int t;     cin >> t;     while (t--) {       cin >> n;       vec.clear();       for (int i = 1; i <= 2 * n; i++) {         p[i] = {0, 0};         grafo[i].clear();         q[i] = 0;         vis[i] = false;         a[i] = b[i] = 0;       }       for (int i = 1; i <= n; i++) {         int x;         cin >> x;         a[x] = i;         q[x]++;         if (p[x].first == 0)           p[x].first = i;         else           p[x].second = i;       }       for (int i = 1; i <= n; i++) {         int x;         cin >> x;         b[x] = i;         q[x]++;         if (p[x].first == 0)           p[x].first = i;         else           p[x].second = i;       }       bool f = true;       for (int i = 1; i <= n; i++)         if (q[i] != 2) f = false;       if (f == false) {         cout << -1 << endl;         continue;       }       for (int i = 1; i <= n; i++) {         int p1 = p[i].first, p2 = p[i].second;         if (a[i] > 0 && b[i] > 0) {           grafo[p1].push_back(p2);           grafo[p2].push_back(p1);           grafo[p1 + n].push_back(p2 + n);           grafo[p2 + n].push_back(p1 + n);         } else {           grafo[p1].push_back(p2 + n);           grafo[p2].push_back(p1 + n);           grafo[p2 + n].push_back(p1);           grafo[p1 + n].push_back(p2);         }       }       vector<int> resp;       for (int i = 1; i <= n; i++) {         if (vis[i] == true) continue;         vec.clear();         dfs(i);         int h = vec.size();         int cnt = 0;         for (int j = 0; j < vec.size(); j++) {           int at = vec[j];           if (at > n) cnt++;         }         if (cnt < h - cnt) {           for (int j = 0; j < vec.size(); j++)             if (vec[j] > n) resp.push_back(vec[j] - n);         } else {           for (int j = 0; j < vec.size(); j++)             if (vec[j] <= n) resp.push_back(vec[j]);         }       }       cout << resp.size() << endl;       for (int i = 0; i < resp.size(); i++) cout << resp[i] <<    ;       cout << endl;     }   }   