#include<iostream>
#include<cstdio>
#include<map>
using namespace std;
long long n,m,f[1001][1001],g[1001],ans,answer,p[1001],s,sz;
map<long long,long long> mp;
int main(){
	scanf("%lld%lld",&n,&m);
	for(long long i=1ll;i<=m;i++){
		for(long long j=1ll;j<=n;j++){
			scanf("%lld",&f[i][j]);
			g[i]=g[i]+f[i][j];
			p[i]=p[i]+f[i][j]*f[i][j];
		}
	}
	for(long long i=1ll;i<m;i++)mp[g[i+1ll]-g[i]]++;
	for(long long i=1ll;i<m;i++){
		if(mp[g[i+1ll]-g[i]]<=2ll)ans=i;
	}
	for(long long i=2ll;i<m;i++){
		if(mp[g[i]-g[i-1ll]]>2ll&&mp[g[i+1ll]-g[i]]>2ll){
			s=(p[i+1ll]-p[i]-p[i]+p[i-1ll])/2ll;
			sz=g[i]-g[i-1ll];
			break;
		}
	}
	sz=sz-g[ans]+g[ans-1ll];
	s=(p[ans+1ll]+p[ans-1ll]-p[ans]-p[ans]-s-s)/2ll;
	answer=(s-sz*sz)/(2ll*sz)+sz; 
	ans--;
	printf("%lld %lld\n",ans,answer);
}
