#include<iostream>
#include<cstring>
#include<cstdio>
#include<climits>
#include<algorithm>
#include<queue>
#include<vector>
#include<bitset>
#include<map>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define mod1 998244353
#define mod2 1000000007
#define LL long long
using namespace std;
inline int read(){
	int f=1,ans=0; char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return f*ans;
}
const int MAXN=1502;
bitset<MAXN> F,G[MAXN],H[MAXN];
int N,M,A[MAXN][MAXN],B[MAXN][MAXN],bas=1503,p[MAXN];
pii A1[MAXN],B1[MAXN]; map<pii,int> Ma;
int Vis[MAXN],Ans[MAXN];
int main(){
	//freopen("A.in","r",stdin);
	N=read(),M=read(); 
	for(int i=1;i<=N;i++){
		for(int j=1;j<=M;j++) A[i][j]=read();
		LL res1=0,res2=0; for(int j=1;j<=M;j++) res1=res1*bas+A[i][j],res2=res2*bas+A[i][j],res1%=mod1,res2%=mod2;
		A1[i]=mp(res1,res2); Ma[mp(res1,res2)]++;
	}
	for(int i=1;i<=N;i++){
		for(int j=1;j<=M;j++) B[i][j]=read();
		LL res1=0,res2=0; for(int j=1;j<=M;j++) res1=res1*bas+B[i][j],res2=res2*bas+B[i][j],res1%=mod1,res2%=mod2;
		B1[i]=mp(res1,res2); if(!Ma[mp(res1,res2)]){printf("-1\n");return 0;}
		Ma[mp(res1,res2)]--;
	}
	for(int i=1;i<=N;i++)
		for(int j=1;j<=N;j++) if(!p[j]&&A1[i]==B1[j]){p[j]=i;break;}
	for(int i=2;i<=N;i++) F[i]=1;
	for(int i=1;i<=M;i++)
		for(int j=2;j<=N;j++) G[i][j]=(B[j][i]>=B[j-1][i]);
	for(int i=1;i<=M;i++){
		for(int j=1;j<=N;j++) H[i][j]=1;
		for(int l=1,r;l<=N;l=r+1){
			r=l; H[i][l]=0; while(B[r+1][i]==B[r][i]) ++r;
		}
	}
	while(1){
		int ps=0; for(int i=1;i<=M;i++) if(!Vis[i]&&(F&G[i])==F){ps=i;break;}
		if(!ps) break;
		Ans[++Ans[0]]=ps; Vis[ps]=1;
		F&=H[ps];
	}
	for(int l=1,r;l<=N;l=r+1){
		r=l; while(F[r+1]) ++r; 
		for(int j=l+1;j<=r;j++) if(p[j-1]>p[j]){printf("-1\n");return 0;}
	}
	printf("%d\n",Ans[0]);
	for(int i=Ans[0];i>=1;i--) printf("%d ",Ans[i]);printf("\n"); return 0;
}/*
3 3
2 3 2
1 3 3
1 1 2
1 1 2
1 3 3
2 3 2
*/