#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
using namespace std;
const int mxn=1e3+3;
ll a[mxn][mxn],n,m;
ll sum[mxn],squsum[mxn];
pair<int,int> delta[mxn];
int err;
ll sumdelta,squsumdelta;
ll orgsum,orgsqusum;
ll sumchange,squsumchange;
ll deltasqusumchange,basesqusumchange;
ll ans;
inline void solve(){
	cin>>n>>m;
	for(int i=1;i<=m;++i)for(int j=1;j<=n;++j)cin>>a[i][j],sum[i]+=a[i][j],squsum[i]+=a[i][j]*a[i][j];
	for(int i=1;i<m;++i)delta[i].first=sum[i+1]-sum[i],delta[i].second=i;
	sort(delta+1,delta+m);
	sumdelta=delta[2].first;
	if(delta[1].second<delta[m-1].second)err=delta[m-1].second;
	else err=delta[1].second;
	if(err==2){
		deltasqusumchange=((squsum[5]-squsum[4])-(squsum[4]-squsum[3]));
		basesqusumchange=(squsum[5]-squsum[4])-deltasqusumchange*3;
	}else{
		basesqusumchange=squsum[2]-squsum[1];
		if(err==3)deltasqusumchange=((squsum[5]-squsum[4])-(squsum[2]-squsum[1]))/3;
		else deltasqusumchange=((squsum[3]-squsum[2])-(squsum[2]-squsum[1]));
	}
	orgsum=sum[err-1]+sumdelta;
	sumchange=orgsum-sum[err];
	orgsqusum=squsum[err-1]+basesqusumchange+deltasqusumchange*(err-2);
	squsumchange=orgsqusum-squsum[err];
	ans=(squsumchange-sumchange*sumchange)/2/sumchange;
	cout<<err-1<<' '<<ans+sumchange<<'\n';
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int T;T=1;
//	cin>>T;
	for(;T--;)solve();
}