#include <bits/stdc++.h>
using namespace std;
template <typename T>
void setmax(T& x, T y) {
  x = max(x, y);
}
template <typename T>
void setmin(T& x, T y) {
  x = min(x, y);
}
const double PI = acos(-1.0);
const int INF = 1e9 + 47;
const long long LINF = 1LL * INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int a[2][1 << 20];
vector<int> pos[1 << 20];
vector<int> g[1 << 20][2];
int u[1 << 20];
vector<int> comp[2];
void dfs(int v, int t = 0) {
  comp[t].push_back(v);
  u[v] = 1;
  for (int to : g[v][0])
    if (!u[to]) dfs(to, t);
  for (int to : g[v][1])
    if (!u[to]) dfs(to, 1 - t);
}
void solve() {
  int n;
  cin >> n;
  for (int i = (0); i < (n); ++i) {
    pos[i + 1].clear();
    for (int j = (0); j < (2); ++j) {
      g[i][j].clear();
    }
    u[i] = 0;
  }
  for (int i = (0); i < (2); ++i) {
    for (int j = (0); j < (n); ++j) {
      cin >> a[i][j];
      pos[a[i][j]].push_back(i * n + j);
    }
  }
  for (int i = (0); i < (n); ++i) {
    if ((int)((pos[i + 1]).size()) != 2) {
      cout << -1 << endl;
      return;
    }
    int ok1 = (pos[i + 1][0] < n);
    int ok2 = (pos[i + 1][1] < n);
    for (int j = (0); j < (2); ++j)
      g[pos[i + 1][j] % n][1 - (ok1 ^ ok2)].push_back(pos[i + 1][1 - j] % n);
  }
  vector<int> ans;
  for (int i = (0); i < (n); ++i) {
    if (u[i]) continue;
    for (int j = (0); j < (2); ++j) comp[j].clear();
    dfs(i);
    int t = ((int)((comp[1]).size()) < (int)((comp[0]).size()));
    for (int v : comp[t]) ans.push_back(v);
  }
  cout << ((int)((ans).size())) << endl;
  for (int i = (0); i < ((int)((ans).size())); ++i) {
    cout << ans[i] % n + 1 << " ";
  }
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int q;
  cin >> q;
  while (q--) {
    solve();
  }
  cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
  return 0;
}
