#include <bits/stdc++.h>

using namespace std;
#define rep(i, l, r) for(auto i=(l);i<=(r);++i)
#define per(i, r, l) for(auto i=(r);i>=(l);--i)
#define N 300030
#define ll long long

struct vec {
	ll s1, s2;
	multiset<ll> pos;

	inline void clear() {
		s1 = s2 = 0, pos.clear();
	}

	inline void insert(ll x) {
		pos.insert(x);
		s1 += x, s2 += 1ll * x * x;
	}

	inline ll erase(ll x) {
		if (!pos.count(x))return 0;
		pos.erase(pos.find(x));
		s1 -= x, s2 -= 1ll * x * x;
		return 1;
	}
} a[N];

ll m, k;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> m >> k;
	rep(i, 1, k) {
		a[i].clear();
		rep(j, 1, m) {
			ll x;
			cin >> x;
			a[i].insert(x);
		}
	}
	ll pos, d = 0;
	set<ll> s;
	rep(i, 2, k)s.insert(a[i].s1 - a[i - 1].s1);
	if (s.size() == 2) {
		d = a[3].s1 - a[2].s1;
		if (a[2].s1 - a[1].s1 != d)pos = 1;
		else pos = k;
	} else {
		d = (a[k].s1 - a[1].s1) / (k - 1);
		assert(((a[k].s1 - a[1].s1) % (k - 1)) == 0);
		rep(i, 2, k - 1) if (a[i].s1 - a[i - 1].s1 != d && a[i + 1].s1 - a[i].s1 != d) {
				pos = i;
				break;
			}
	}
	cout << pos - 1 << ' ';
	ll v2 = 0;
	rep(i, 1, k - 2) if (i != pos && i + 1 != pos && i + 2 != pos) {
			v2 = a[i].s2 + a[i + 2].s2 - 2ll * a[i + 1].s2;
			break;
		}
	ll p1, p2, p3;
	if (pos == 1)p1 = 1, p2 = 2, p3 = 3;
	else if (pos == k)p1 = k - 2, p2 = k - 1, p3 = k;
	else p1 = pos - 1, p2 = pos, p3 = pos + 1;

	vec o = a[pos];
	for (auto v:o.pos) {
		a[pos].erase(v);
		ll l = a[p1].s1 + a[p3].s1, r = 2ll * a[p2].s1;
		ll y = (l < r) ? (r - l) : ((l - r) / 2ll);
		a[pos].insert(y);
		ll v3 = a[p1].s2 + a[p3].s2 - 2ll * a[p2].s2;
		if (v3 != v2 || a[p1].s1 + a[p3].s1 != 2ll * a[p2].s1) {
			a[pos].erase(y), a[pos].insert(v);
			continue;
		}
		cout << y << endl;
		break;
	}
}
