#include <bits/stdc++.h>
using namespace std;

const int N = 1505, mod = 1e9 + 9;

int n, m, b[N][N], v[N], d[N], ans[N], tot;

bool vis[N], op[N];

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) {
		for (int j = 1, x; j <= m; j++)
			scanf("%d", &x), v[i] = (v[i]*233ll + x)%mod;
	}
	for (int i = 1, k; i <= n; i++) {
		k = 0;
		for (int j = 1; j <= m; j++) 
			scanf("%d", &b[i][j]), k = (k*233ll + b[i][j])%mod;
		for (int j = 1; j <= n; j++) 
			if (!vis[j] && v[j] == k) {
				vis[j] = 1, b[i][m + 1] = j;
				break;
			}
		if (!b[i][m + 1])
			return puts("-1"), 0;
	}
	for (int i = 1; i <= m + 1; i++)
		for (int j = 1; j < n; j++)
			d[i] += b[j][i] > b[j + 1][i];
	memset(vis, 0, sizeof(vis));
	for (int k = 1; k <= m + 1; k++) {
		int x = 0;
		for (int i = m + 1; i; i--)
			if (!vis[i] && !d[i]) {
				vis[i] = 1, x = i;
				break;
			}
		if (!x)
			return puts("-1"), 0;
		if (x == m + 1) {
			printf("%d\n", tot);
			for (int i = tot; i; i--)
				printf("%d ", ans[i]);
			return 0;
		}
		ans[++tot] = x;
		for (int i = 1; i < n; i++)
			if (b[i][x] < b[i + 1][x] && !op[i]) {
				op[i] = 1;
				for (int j = 1; j <= m + 1; j++)
					d[j] -= b[i][j] > b[i + 1][j];
			} 	
	}
}