func_code_string: #include <bits/stdc++.h>   void build_comp(int v, int comp_num, std::vector<int> &cur_comp,                   std::vector<int> &rev_comps,                   const std::vector<std::vector<int>> &g) {     cur_comp.push_back(v);     rev_comps[v] = comp_num;     for (int to : g[v]) {       if (rev_comps[to] == -1) {         build_comp(to, comp_num, cur_comp, rev_comps, g);       }     }   }   void solve() {     int n;     std::cin >> n;     std::vector<std::vector<std::pair<int, int>>> positions(n);     const auto reader = [n, &positions](int num) {       for (int i = 0; i < n; ++i) {         int a;         std::cin >> a;         positions[a - 1].emplace_back(num, i);       }     };     const auto neg = [n](int val) { return (val + n) % (2 * n); };     reader(0);     reader(1);     for (int i = 0; i < n; ++i) {       if (positions[i].size() != 2) {         std::cout << -1 <<   n ;         return;       }     }     std::vector<std::vector<int>> g(2 * n);     for (int i = 0; i < n; ++i) {       auto pa = positions[i][0];       auto pb = positions[i][1];       if (pa.second == pb.second) {         continue;       }       int a = pa.second;       int b = pb.second;       if (pa.first == pb.first) {         a = neg(a);       }       g[a].push_back(b);       g[b].push_back(a);       g[neg(a)].push_back(neg(b));       g[neg(b)].push_back(neg(a));     }     int comp_num = 0;     std::vector<std::vector<int>> comps;     std::vector<int> rev_comps(2 * n, -1);     for (int i = 0; i < 2 * n; ++i) {       if (rev_comps[i] == -1) {         std::vector<int> cur_comp;         build_comp(i, comp_num++, cur_comp, rev_comps, g);         comps.emplace_back(std::move(cur_comp));       }     }     for (int i = 0; i < n; ++i) {       if (rev_comps[i] == rev_comps[neg(i)]) {         std::cout << -1 <<   n ;         return;       }     }     std::set<int> res;     std::set<size_t> skipping_comps;     for (size_t i = 0; i < comps.size(); ++i) {       if (skipping_comps.find(i) != skipping_comps.end()) {         continue;       }       const auto &line = comps[i];       int positive = 0;       for (int v : line) {         if (v < n) {           ++positive;         }       }       int negative = line.size() - positive;       if (positive <= negative) {         for (int v : line) {           if (v < n) {             res.insert(v);           }         }       }       if (positive == negative) {         skipping_comps.insert(rev_comps[neg(line[0])]);       }     }     std::cout << res.size() <<   n ;     for (int v : res) {       std::cout << v + 1 <<    ;     }     std::cout <<   n ;   }   int main() {     int t;     std::cin >> t;     for (; t; --t) {       solve();     }     return 0;   }   