using namespace std;
#include <bits/stdc++.h>
#define N 1505
int input(){
	char ch=getchar();
	while (ch<'0' || ch>'9')
		ch=getchar();
	int x=0;
	do{
		x=x*10+ch-'0';
		ch=getchar();
	}
	while ('0'<=ch && ch<='9');
	return x;
}
int n,m;
int a[N][N],b[N][N];
int f[N][N];
int suc[N],vis[N],cnt;
int bz[N];
int used[N];
int ls[N],nl;
int q[N];
bool cmp(int x,int y){
	for (int i=1;i<=nl;++i){
		if (a[x][ls[i]]<a[y][ls[i]]) return 1;	
		if (a[x][ls[i]]>a[y][ls[i]]) return 0;
	}
	return 0;
}
int main(){
//	freopen("in.txt","r",stdin);
	n=input(),m=input();
	for (int i=1;i<=n;++i)	
		for (int j=1;j<=m;++j)
			a[i][j]=input();
	for (int i=1;i<=n;++i)
		for (int j=1;j<=m;++j)
			b[i][j]=input();
	for (int j=1;j<=m;++j)
		f[1][j]=1;
	for (int i=2;i<=n;++i)
		for (int j=1;j<=m;++j)
			f[i][j]=(b[i-1][j]<=b[i][j]?f[i-1][j]:i);
	cnt=1;
	vis[n]=1;
	for (int j=1;j<=m;++j)
		bz[j]+=(f[n][j]<=1);
	suc[0]=n;
	while (1){
		int p=0;
		for (int j=1;j<=m;++j)
			if (!used[j] && bz[j]==cnt){
				p=j;
				break;
			}
		if (p==0)
			break;
		used[p]=1;
		ls[++nl]=p;
		for (int i=1,lst=0;i<n;++i)
			if (b[i][p]!=b[i+1][p] && !vis[i]){
				cnt++;
				vis[i]=1;
				for (int j=1;j<=m;++j)
					bz[j]+=(f[i][j]<=lst+1)+(f[suc[lst]][j]<=i+1)-(f[suc[lst]][j]<=lst+1);
				suc[i]=suc[lst];
				suc[lst]=i;
				lst=i;
			}
			else if (vis[i])
				lst=i;
	}
	for (int i=1;i<=n;++i)
		q[i]=i;
	stable_sort(q+1,q+n+1,cmp);
	for (int i=1;i<=n;++i)
		for (int j=1;j<=m;++j)
			if (a[q[i]][j]!=b[i][j]){
				printf("-1\n");
				return 0;
			}
	printf("%d\n",nl);
	for (int i=nl;i>=1;--i)
		printf("%d ",ls[i]);
	return 0;
}













