# include <bits/stdc++.h>
using namespace std;
const int N=1e3+10;
int n,m,a[N][N],sum1[N],sum2[N],c1[N],c2[N],c3[N];
map<int,int>mp,tt;
signed main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++) 
		for (int j=1;j<=n;j++) {
			scanf("%d",&a[i][j]);
			sum1[i]+=a[i][j];
			sum2[i]+=a[i][j]*a[i][j];
		}	
	for (int i=1;i<=m;i++) {
		c1[i]=sum1[i]-sum1[i-1];
		c2[i]=sum2[i]-sum2[i-1];
		if (i>1) mp[c1[i]]++,tt[c1[i]]=i;
	}
	int id=m;
	for (map<int,int>::iterator it=mp.begin();it!=mp.end();it++) {
		if ((it->second)==1) id=min(id,tt[it->first]);
	}
	for (int i=1;i<=m;i++) c3[i]=c2[i]-c2[i-1];
	int res;
	if (id>=4) res=c3[3]; else res=c3[7]; 
	
	if (id!=2) {
		for (int i=3;i<=m;i++) c3[i]=res;
		for (int i=1;i<=m;i++) c3[i]=c3[i-1]+c3[i];
		for (int i=1;i<=m;i++) c3[i]=c3[i-1]+c3[i];
	} else {
		int d=sum2[m]-sum2[m-1]-sum2[m-1]+sum2[m-2];
		c3[m]=sum2[m]-sum2[m-1];
		for (int i=m-1;i>=2;i--) c3[i]=c3[i+1]-d;
		for (int i=1;i<=m;i++) c3[i]=c3[i-1]+c3[i];
	}
	if (id>=4) res=c1[3]; else res=c1[7];
	if (id!=2) {
		for (int i=3;i<=m;i++) c1[i]=res;
		for (int i=1;i<=m;i++) c1[i]=c1[i-1]+c1[i];
	} else {
		int d=sum1[m]-sum1[m-1]-sum1[m-1]+sum1[m-2];
		c1[m]=sum1[m]-sum1[m-1];
		for (int i=m-1;i>=2;i--) c1[i]=c1[i+1]-d;
		for (int i=1;i<=m;i++) c1[i]=c1[i-1]+c1[i];
	}
	int ans1=id-1,ans2;
	for (int i=1;i<=n;i++) {
		int t=c1[id]-(sum1[id]-a[id][i]);
		if (t*t+sum2[id]-a[id][i]*a[id][i]==c3[id]) {
			ans2=t; break;
		}
	}
	printf("%d %d\n",ans1,ans2);
	fflush(stdout);
	return 0;
}

/*
by maystern
*/