#include <bits/stdc++.h>
#define fo(a,b,c) for (a=b; a<=c; a++)
#define fd(a,b,c) for (a=b; a>=c; a--)
#define ll long long
//#define file
using namespace std;

int n,K,i,j,k,l;
int a[1001][1001];ll sum[1001];
ll Ans1,Ans2;
ll A,ans;
ll X[4],Y[4];
double Ans,s,ssum;

int main()
{
	#ifdef file
	freopen("d.in","r",stdin);
	#endif
	
	scanf("%d%d",&n,&K);
	fo(i,0,K-1) fo(j,0,n-1) scanf("%d",&a[i][j]),sum[i]+=a[i][j];
	
	fo(i,1,K-2)
	if (sum[i]-sum[i-1]!=(sum[K-1]-sum[0])/(K-1))
	{
		Ans1=i;
		A=(sum[i]-sum[i-1])-(sum[K-1]-sum[0])/(K-1);
		fo(j,0,n-1) ans+=1ll*a[i][j]*a[i][j];
		break;
	}
	ans-=A*A;
	
	l=0;
	fo(i,0,3)
	if (i!=Ans1 && l<3)
	{
		X[++l]=i;
		fo(j,0,n-1) Y[l]+=1ll*a[i][j]*a[i][j];
	}
	fo(i,1,3)
	{
		s=Y[i];
		fo(j,1,3) if (i!=j) s=s*(Ans1-X[j])/(X[i]-X[j]);
		ssum+=s;
	}
	ans-=floor(ssum+0.5);
	
	Ans2=ans/(A*2);
	printf("%lld %lld\n",Ans1,Ans2);
	
	fclose(stdin);
	fclose(stdout);
	return 0;
}