#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1005;
ll arr[maxn][maxn];
ll s[maxn] = {0}, s2[maxn] = {0};

void solve()
{
	int m, k;
	cin >> m >> k;
	for (int i = 0; i < k; i++)
	{
		for (int j = 0; j < m; j++)
		{
			cin >> arr[i][j];
			s[i] += arr[i][j];
			s2[i] += arr[i][j] * arr[i][j];
		}
	}
	ll row = -1, change = 0;
	ll d = 0;
	if (s[1] - s[0] == s[2] - s[1])
		d = s[1] - s[0];
	else
		d = s[5] - s[4];
	for (int i = 1; i < k; i++)
		if (s[i] - s[i - 1] != d)
		{
			change = d - s[i] + s[i - 1];
			row = i;
			break;
		}

	cout << row << " ";
	ll v2 = 0;
	if (row <= 2)
		v2 = s2[5] + s2[3] - 2 * s2[4];
	else
		v2 = s2[2] + s2[0] - 2 * s2[1];
	for (int i = 0; i < m; i++)
	{
		ll ov = arr[row][i];
		ll nv = arr[row][i] + change;
		ll ns = s2[row] - ov * ov + nv * nv;
		if (s2[row + 1] + s2[row - 1] - 2 * ns == v2)
		{
			cout << nv << endl;
			return;
		}
	}
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout.precision(10);
	cout << fixed;
	// iota(tree, tree + maxn, 0);
#ifdef LOCAL
	freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
#endif

	solve();

#ifdef LOCAL
	cerr << endl;
	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}