#include <cstdio>
#include <algorithm>

int read() {
  static int c, x;
  while ((c = getchar()) < 48) {}
  x = c & 15;
  while ((c = getchar()) >= 48) x = x * 10 + (c & 15);
  return x;
}

#define MAXN 1510

int n, m;
bool vis[MAXN];
int orda[MAXN], ordb[MAXN], pos[MAXN], cnt[MAXN], q[MAXN];
bool lft[MAXN][MAXN];
int a[MAXN][MAXN], b[MAXN][MAXN];

bool cmpa(const int &x, const int &y) {
  for (int i = 1; i <= m; ++i)
    if (a[x][i] != a[y][i]) return a[x][i] < a[y][i];
  return x < y;
}
bool cmpb(const int &x, const int &y) {
  for (int i = 1; i <= m; ++i)
    if (b[x][i] != b[y][i]) return b[x][i] < b[y][i];
  return x < y;
}

int main() {
  n = read();
  m = read();
  for (int i = 1; i <= n; ++i) {
    orda[i] = i;
    for (int j = 1; j <= m; ++j) {
      a[i][j] = read();
    }
  }
  for (int i = 1; i <= n; ++i) {
    ordb[i] = i;
    for (int j = 1; j <= m; ++j) {
      b[i][j] = read();
    }
  }
  std::sort(orda + 1, orda + n + 1, cmpa);
  std::sort(ordb + 1, ordb + n + 1, cmpb);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (a[orda[i]][j] != b[ordb[i]][j]) {
        puts("-1");
        return 0;
      }
      if (b[i - 1][j] > b[i][j]) {
        ++cnt[j];
        lft[i][j] = true;
      }
    }
    pos[ordb[i]] = i;
  }
  int tl = 0;
  for (int i = 1; i <= m; ++i) {
    if (!cnt[i]) q[++tl] = i;
  }
  for (int hd = 1; hd <= tl; ++hd) {
    const int x = q[hd];
    for (int i = 2; i <= n; ++i) {
      if (!vis[i] && b[i - 1][x] < b[i][x]) {
        vis[i] = true;
        for (int j = 1; j <= m; ++j) {
          if (lft[i][j]) {
            lft[i][j] = false;
            if (!--cnt[j]) q[++tl] = j;
          }
        }
      }
    }
  }
  for (int i = 2; i <= n; ++i) {
    if (!vis[i] && orda[pos[i - 1]] > orda[pos[i]]) {
      puts("-1");
      return 0;
    }
  }
  printf("%d\n", tl);
  for (int i = tl; i >= 1; --i) printf("%d ", q[i]);
  return 0;
}
