#include <bits/stdc++.h>

#define mp std::make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define gc getchar
#define pc putchar

typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef std::pair <int, int> pii;
typedef std::pair <ll, ll> pll;

const ll max_N = 1049;

ll m, K, A[max_N][max_N], sum1[max_N], sum2[max_N];

ll read_ll() {
	char c = gc(); ll ans = 0; bool neg = false;
	while (!isdigit(c)) neg |= (c == '-'), c = gc();
	while (isdigit(c)) ans = 10 * ans + c - '0', c = gc();
	return neg ? -ans : ans;
}

void write_ll(ll x) {
	if (x < 0) pc('-'), x = -x;
	if (x > 9) write_ll(x / 10);
	pc(x % 10 + '0');
}

ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll x, ll y) {return x > y ? x : y;}
void _min(ll &x, ll y) {if (x > y) x = y;}
void _max(ll &x, ll y) {if (x < y) x = y;}

int main() {
	m = read_ll(), K = read_ll();
	for (ll i = 0; i < K; i++)
		for (ll j = 1; j <= m; j++) A[i][j] = read_ll();
	for (ll i = 0; i < K; i++)
		for (ll j = 1; j <= m; j++)
			sum1[i] += A[i][j], sum2[i] += A[i][j] * A[i][j];
	std::adjacent_difference(sum1, sum1 + K, sum1);
	ll average = std::accumulate(sum1 + 1, sum1 + K, 0ll) / (K - 1);
	for (ll i = 1, _; i < K; i++) {
		if (sum1[i] == average) continue;
		if (i + 3 < K) _ = sum2[i + 1] - (2 * (sum2[i + 2] - sum2[i + 1]) - (sum2[i + 3] - sum2[i + 2]));
		else _ = sum2[i - 1] + (2 * (sum2[i - 1] - sum2[i - 2]) - (sum2[i - 2] - sum2[i - 3]));
		for (ll j = 1; j <= m; j++) {
			ll tmp = A[i][j] + average - sum1[i];
			if (sum2[i] - A[i][j] * A[i][j] + tmp * tmp == _)
				return write_ll(i), pc(' '), write_ll(tmp), pc('\n'), 0;
		}
		abort();
	}
	return abort(), 0;
}
