#include <bits/stdc++.h>
using namespace std;
vector<vector<pair<int, int>>> g;
vector<int> color;
vector<bool> vis;
int cnt0, cnt1;
vector<int> ans;
void dfs1(int cur, int c) {
  if (color[cur] != -1) return;
  color[cur] = c;
  if (color[cur] == 0)
    cnt0++;
  else
    cnt1++;
  for (auto nbr : g[cur]) {
    dfs1(nbr.first, c ^ nbr.second);
  }
}
void dfs2(int cur, int c) {
  if (vis[cur]) return;
  if (color[cur] == c) ans.push_back(cur);
  vis[cur] = true;
  for (auto nbr : g[cur]) {
    dfs2(nbr.first, c);
  }
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  auto solve = []() {
    int n;
    cin >> n;
    vector<vector<pair<int, int>>> col(n);
    for (int i = 0; i < 2; i++) {
      for (int j = 0; j < n; j++) {
        int x;
        cin >> x;
        col[--x].emplace_back(i, j);
      }
    }
    g = vector<vector<pair<int, int>>>(n);
    for (int i = 0; i < n; i++) {
      if ((int)col[i].size() != 2) {
        cout << -1 << '\n';
        return;
      }
      int c1 = col[i][0].second, c2 = col[i][1].second;
      int r1 = col[i][0].first, r2 = col[i][1].first;
      if (c1 == c2) continue;
      if (r1 == r2) {
        g[c1].emplace_back(c2, 1);
        g[c2].emplace_back(c1, 1);
      } else {
        g[c1].emplace_back(c2, 0);
        g[c2].emplace_back(c1, 0);
      }
    }
    color = vector<int>(n, -1);
    vis = vector<bool>(n, false);
    ans.clear();
    for (int i = 0; i < n; i++) {
      if (color[i] == -1) {
        cnt0 = cnt1 = 0;
        dfs1(i, 0);
        if (cnt0 <= cnt1) {
          dfs2(i, 0);
        } else {
          dfs2(i, 1);
        }
      }
    }
    for (int i = 0; i < n; i++) {
      for (auto nbr : g[i]) {
        if ((color[i] ^ color[nbr.first]) != nbr.second) {
          cout << -1 << '\n';
          return;
        }
      }
    }
    cout << ans.size() << '\n';
    for (int i = 0; i < (int)ans.size(); i++) {
      if (i > 0) cout << " ";
      cout << ans[i] + 1;
    }
    cout << '\n';
  };
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
