#include <bits/stdc++.h>

using namespace std;

int n, m, wtf[1505];
bool ok[1505];
vector<int> r[1505];
vector<vector<int>> x, y;
vector<int> ans;
queue<int> q;

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++) {
		x.emplace_back(m + 1);
		for (int j = 0; j < m; j++)
			scanf("%d", &x.back()[j]);
		x.back()[m] = i;
	}
	sort(x.begin(), x.end());
	for (int i = 0; i < n; i++) {
		y.emplace_back(m + 1);
		for (int j = 0; j < m; j++)
			scanf("%d", &y.back()[j]);
		int tmp = lower_bound(x.begin(), x.end(), y.back()) - x.begin();
		if (tmp != n)
			for (int j = 0; j < m; j++)
				if (x[tmp][j] != y.back()[j]) {
					tmp = n;
					break;
				}
		if (tmp == n) {
			puts("-1");
			return 0;
		}
		y.back().back() = x[tmp].back();
		x[tmp].back() = -1;
	}
	// for (auto& i : x) { printf("x: "); for (int j : i) printf("%d ", j); puts(""); }
	// for (auto& i : y) { printf("y: "); for (int j : i) printf("%d ", j); puts(""); }
	for (int i = 0; i <= m; i++) {
		for (int j = 0; j + 1 < n; j++)
			if (y[j][i] > y[j + 1][i]) {
				wtf[i]++;
				r[j].push_back(i);
			}
		// printf("wtf[%d]=%d\n", i, wtf[i]);
		if (wtf[i] == 0) {
			if (i == m) {
				puts("0");
				return 0;
			}
			q.push(i);
		}
	}
	int did = 0;
	while (!q.empty()) {
		int tmp = q.front();
		q.pop();
		ans.push_back(tmp + 1);
		for (int i = 0; i + 1 < n; i++)
			if (!ok[i] && y[i][tmp] < y[i + 1][tmp]) {
				ok[i] = 1;
				for (int j : r[i])
					if (--wtf[j] == 0) {
						if (j == m) {
							reverse(ans.begin(), ans.end());
							printf("%d\n", (int)ans.size());
							for (int k = 0; k < ans.size(); k++)
								printf("%d%c", ans[k], " \n"[k == ans.size() - 1]);
							return 0;
						}
						q.push(j);
					}
			}
	}
	puts("-1");
}
