#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,pos,qwq,delta,a[1009],b[1009],p[1009][1009];
inline ll read(){
	ll s = 0,w = 1;
	char ch = getchar();
	while (ch > '9' || ch < '0'){ if (ch == '-') w = -1; ch = getchar();}
	while (ch <= '9' && ch >= '0') s = (s << 1) + (s << 3) + (ch ^ 48),ch = getchar();
	return s * w;
}
int main(){
	m = read(),n = read();
	for (ll i = 1;i <= n;i += 1) for (ll j = 1;j <= m;j += 1) p[i][j] = read(),a[i] += p[i][j],b[i] += p[i][j] * p[i][j];
	for (ll i = 2;i < n;i += 1) if (a[i] - a[i - 1] != (a[n] - a[1]) / (n - 1)){pos = i,delta = a[i] - a[i - 1] - (a[n] - a[1]) / (n - 1); break;}
	if (pos <= 3) qwq = b[n - 2] + b[n] - 2 * b[n - 1];
	else qwq = b[1] + b[3] - 2 * b[2];
	for (ll i = 1;i <= m;i += 1) if (b[pos - 1] + b[pos + 1] - 2 * (b[pos] - p[pos][i] * p[pos][i] + (p[pos][i] - delta) * (p[pos][i] - delta)) == qwq){printf("%lld %lld",pos - 1,p[pos][i] - delta); return 0;}
	return 0;
}