#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
inline int read() {
  int x = 0;
  int f = 0;
  char ch = 0;
  while (!isdigit(ch)) {
    f |= (ch == '-') ? 1 : 0;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  return f ? -x : x;
}
const int maxn = 2e5 + 10;
int aa[3][maxn];
int vis[maxn], vis1[maxn];
int in[maxn][2], out[maxn][2];
int cnt = 0, cnt1, cnt3;
int st[maxn];
int st1[maxn], st3[maxn];
set<int> temp;
int t, n;
vector<int> vv;
inline void dfs(int u, int fa) {
  vis1[u] = 1;
  st3[++cnt3] = u;
  st[++cnt] = aa[1][u];
  if (cnt1) {
    if (aa[1][u] != st1[cnt1])
      st1[++cnt1] = aa[1][u];
    else
      st1[++cnt1] = aa[2][u];
  } else {
    if (aa[1][out[u][0]] == aa[1][u] || aa[1][out[u][0]] == aa[2][u])
      st1[++cnt1] = aa[1][out[u][0]];
    else
      st1[++cnt1] = aa[2][out[u][0]];
  }
  for (int i = 0; i <= 1; ++i) {
    int v = out[u][i];
    if (v == fa) continue;
    if (!vis1[v]) dfs(v, u);
  }
}
int main() {
  t = read();
  while (t--) {
    n = read();
    for (int i = 1; i <= n; ++i)
      vis[i] = vis1[i] = 0, out[i][0] = out[i][1] = in[i][0] = in[i][1] = -1;
    for (int i = 1; i <= 2; ++i)
      for (int j = 1; j <= n; ++j) aa[i][j] = read(), ++vis[aa[i][j]];
    int flag = 0;
    for (int i = 1; i <= n; ++i) {
      if (aa[1][i] == aa[2][i]) {
        vis1[i] = 1;
      } else {
        if (in[aa[1][i]][0] == -1)
          in[aa[1][i]][0] = i;
        else
          in[aa[1][i]][1] = i;
        if (in[aa[2][i]][0] == -1)
          in[aa[2][i]][0] = i;
        else
          in[aa[2][i]][1] = i;
      }
      if (vis[i] != 2) {
        flag = 1;
        break;
      }
    }
    if (flag) {
      printf("-1\n");
      continue;
    }
    for (int i = 1; i <= n; ++i) {
      if (out[in[i][0]][0] == -1) {
        out[in[i][0]][0] = in[i][1];
      } else {
        out[in[i][0]][1] = in[i][1];
      }
      if (out[in[i][1]][0] == -1) {
        out[in[i][1]][0] = in[i][0];
      } else {
        out[in[i][1]][1] = in[i][0];
      }
    }
    int ans = 0;
    vv.clear();
    for (int i = 1; i <= n; ++i)
      if (!vis1[i]) {
        cnt = cnt1 = cnt3 = 0;
        temp.clear();
        dfs(i, 0);
        int tmp = 0;
        for (int i = 1; i <= cnt; ++i)
          if (st[i] == st1[i]) ++tmp;
        ans += min(tmp, cnt - tmp);
        if (tmp < cnt - tmp) {
          for (int i = 1; i <= cnt; ++i)
            if (st[i] == st1[i]) vv.push_back(st3[i]);
        } else
          for (int i = 1; i <= cnt; ++i)
            if (st[i] != st1[i]) vv.push_back(st3[i]);
      }
    printf("%d\n", ans);
    for (int i = 0; i < vv.size(); ++i) {
      if (i) printf(" ");
      printf("%d", vv[i]);
    }
    printf("\n");
  }
}
