#include <bits/stdc++.h>
using namespace std;
vector<int> c;
vector<vector<int>> z;
vector<vector<vector<int>>> edges;
vector<int> a, b;
void dfs(int ver) {
  for (auto e : edges[ver]) {
    if (!c[e[0]]) {
      if (e[1]) {
        if (c[ver] == 1)
          c[e[0]] = 2, b.push_back(e[0]);
        else
          c[e[0]] = 1, a.push_back(e[0]);
      } else {
        if (c[ver] == 1)
          c[e[0]] = 1, a.push_back(e[0]);
        else
          c[e[0]] = 2, b.push_back(e[0]);
      }
      dfs(e[0]);
    }
  }
}
inline void test_case() {
  int n;
  cin >> n;
  z.assign(n + 1, {});
  for (int r = 0; r < 2; r++) {
    for (int c = 1; c <= n; c++) {
      int x;
      cin >> x;
      z[x].push_back(r);
      z[x].push_back(c);
    }
  }
  edges.assign(n + 1, {});
  for (int i = 1; i <= n; i++) {
    if (z[i].size() != 4) {
      cout << "-1\n";
      return;
    }
    edges[z[i][1]].push_back({z[i][3], (z[i][0] == z[i][2] ? 1 : 0)});
    edges[z[i][3]].push_back({z[i][1], (z[i][0] == z[i][2] ? 1 : 0)});
  }
  vector<int> ans;
  c.assign(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    if (!c[i]) {
      c[i] = 1, a.push_back(i);
      dfs(i);
      if (a.size() < b.size()) {
        for (int j : a) ans.push_back(j);
      } else {
        for (int j : b) ans.push_back(j);
      }
      a.clear(), b.clear();
    }
  }
  cout << ans.size() << '\n';
  for (int i : ans) cout << i << " ";
  cout << '\n';
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  for (int i = 1; i <= t; i++) test_case();
  return 0;
}
