#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
	cin.tie(0) -> sync_with_stdio(0);

	int n, k;
	cin >> n >> k;
	vector<ll> sm(k, 0), smq(k, 0);
	for(int i = 0; i < k; i ++){
		for(int x, j = 0; j < n; j ++){
			cin >> x;
			sm[i] += (ll)x;
			smq[i] += (ll)x * 1ll * x;
		}
	}

	vector<int> diffs;
	for(int i = 1; i < k; i ++)
		diffs.push_back(sm[i] - sm[i - 1]);
	sort(diffs.begin(), diffs.end());
	ll actual_df = diffs[1];
	int ps = -1;
	for(int i = 1; i + 1 < k; i ++)
		if(sm[i] != sm[0] + actual_df * 1ll * i)
			ps = i;
	
	ll df = (sm[ps - 1] + actual_df) - sm[ps]; // expected - actual

	ll valid = 0ll;
	if(ps <= 2)
		valid = smq[3] + smq[5] - 2ll * smq[4];
	else
		valid = smq[0] + smq[2] - 2ll * smq[1];

	ll difsq = 0ll;
	if(ps == k - 2)
		difsq = valid - (smq[ps] + smq[ps - 2] - 2ll * smq[ps - 1]);
	else
		difsq = valid - (smq[ps] + smq[ps + 2] - 2ll * smq[ps + 1]);

	ll ans = (df + difsq / df) / 2;
	cout << ps << " " << ans << endl;
	return 0;
}