#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)

const int N = 1 << 10;
int p[N][N];
int main()
{
	int m, n;
	cin >> m >> n;
	FOR(i, 0, n)
	FOR(j, 0, m)
		cin >> p[i][j];
	int sum = 0;
	FOR(j, 0, m)
		sum += p[n - 1][j] - p[0][j];
	assert(sum%(n - 1) == 0);
	sum /= (n - 1);
	int sum0 = 0;
	FOR(j, 0, m)
		sum0 += p[0][j];
	int row = 0;
	FOR(i, 1, n - 1){
		int S = 0;
		FOR(j, 0, m)
			S += p[i][j];
		if(S == sum0 + i * sum) continue;
		row = i;
	}
	int st = (row > 2 ? 0 : (row + 1));
	LL sum2 = 0;
	FOR(j, 0, m){
		sum2 += p[st][j] * (LL) p[st][j];
		sum2 += p[st + 2][j] * (LL) p[st + 2][j];
		sum2 -= 2 * p[st + 1][j] * (LL) p[st + 1][j];
	}
	sum2 /= 2;
	LL real = 0, real2 = 0, have = 0, have2 = 0;
	FOR(j, 0, m){
		have += p[row][j];
		have2 += p[row][j] * (LL) p[row][j];
		real += p[row - 1][j];
		real2 += p[row - 1][j] * (LL) p[row - 1][j];
		real2 += p[row + 1][j] * (LL) p[row + 1][j];
	}
	real += sum;
	real2 = real2/2 - sum2;
	LL a2_x2 = have2 - real2;
	LL a_x = have - real;
	LL a_plus_x = a2_x2 / a_x;
	cout << row << " " << (a_plus_x - a_x) / 2 << endl;
	return 0;
}

