#include <bits/stdc++.h>
using namespace std;
int n, m, i, j, k, ans1, ans2;
typedef long long ll;
ll A[1100][1100];
ll C[1100], x, y, s, t, temp;

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++)
		for (int j = 1; j <= n; j++) {
			scanf("%lld", &A[i][j]);
			C[i] += A[i][j];
		}
	x = (C[m - 1] - C[0]) / (m - 1);
	for (int i = 1; i < m; i++)
		if ((C[i] - C[0]) != x * i) {
			ans1 = i;
			y = C[i] - C[0] - x * i;
			break;
		}
	for (int i = 1; i < m - 1; i++)
		if (i - 1 != ans1 && i != ans1 && i + 1 != ans1) {
			x = 0;
			for (int j = 1; j <= n; j++)
				x += A[i - 1][j] * A[i - 1][j] + A[i + 1][j] * A[i + 1][j] - A[i][j] * A[i][j] * 2;
			break;
		}
	i = ans1;
	t = s = 0;
	for (j = 1; j <= n; j++) {
		s += A[i - 1][j] * A[i - 1][j] + A[i + 1][j] * A[i + 1][j];
		t += A[i][j] * A[i][j] * 2;
	}
	s -= x;
	for (j = 1; j <= n; j++) {
		temp = t - A[i][j] * A[i][j] * 2 + (A[i][j] - y) * (A[i][j] - y) * 2;
		if (temp == s) {
			ans2 = A[i][j] - y;
			break;
		}
	}
	printf("%d %d\n", ans1, ans2);
}