#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0;
  bool t = false;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') t = true, ch = getchar();
  while (ch <= '9' && ch >= '0') x = x * 10 + ch - 48, ch = getchar();
  return t ? -x : x;
}
int n, a[3][400400], cnt[400400];
struct P {
  int x, y;
} p[400400][3];
int f[400400], val[400400], cho[400400];
int getf(int x) { return (f[x] == x) ? x : (f[x] = getf(f[x])); }
void Link(int x, int y) {
  if (getf(x) == getf(y)) return;
  val[getf(y)] += val[getf(x)];
  f[getf(x)] = getf(y);
}
int main() {
  int T = read();
  while (T--) {
    n = read();
    bool fl = true;
    for (int i = 1; i <= 2; ++i)
      for (int j = 1; j <= n; ++j) a[i][j] = read();
    for (int i = 1; i <= 2; ++i)
      for (int j = 1; j <= n; ++j)
        if (a[i][j] < 1 || a[i][j] > n) fl = false;
    if (!fl) {
      puts("-1");
      continue;
    }
    for (int i = 1; i <= n; ++i) cnt[i] = 0;
    for (int i = 1; i <= 2; ++i)
      for (int j = 1; j <= n; ++j) p[a[i][j]][++cnt[a[i][j]]] = (P){i, j};
    for (int i = 1; i <= n; ++i)
      if (cnt[i] != 2) fl = false;
    int ans = 0;
    for (int i = 1; i <= n + n; ++i) f[i] = i, val[i] = (i <= n);
    for (int i = 1; i <= n; ++i)
      if (p[i][1].x == p[i][2].x)
        Link(p[i][1].y, p[i][2].y + n), Link(p[i][1].y + n, p[i][2].y);
      else
        Link(p[i][1].y, p[i][2].y), Link(p[i][1].y + n, p[i][2].y + n);
    for (int i = 1; i <= n; ++i)
      if (getf(i) == getf(i + n)) fl = false;
    if (!fl) {
      puts("-1");
      continue;
    }
    for (int i = 1; i <= n + n; ++i) cho[i] = 0;
    for (int i = 1; i <= n; ++i)
      if (getf(i) == i) {
        if (val[getf(i)] < val[getf(i + n)])
          cho[getf(i)] = 1;
        else
          cho[getf(i + n)] = 1;
        ans += min(val[getf(i)], val[getf(i + n)]);
      }
    printf("%d\n", ans);
    for (int i = 1; i <= n; ++i)
      if (cho[getf(i)]) printf("%d ", i);
    if (ans) puts("");
  }
  return 0;
}
