#include<bits/stdc++.h>
#define cs const
#define pb push_back
using namespace std;
typedef long long ll;
cs int N = 1e3 + 5; 
int n, m; ll a[N][N];
ll b[N], c[N];
int main() {
	#ifdef FSYo
	freopen("1.in", "r", stdin);
	#endif
	cin >> n >> m; 
	for(int i = 0; i < m; i++)
	for(int j = 0; j < n; j++) {
		scanf("%lld", &a[i][j]);
		b[i] += a[i][j], c[i] += a[i][j] * a[i][j];
	}
	map<int, int> t; 
	for(int i = 1; i < m; i++)
		t[b[i] - b[i - 1]] ++;
	ll delta = 0; 
	for(auto x : t) if(x.second > 2) delta = x.first; 
	for(int i = 1; i < m; i++) 
	if(b[i] - b[i - 1] != delta) {
		ll d = delta - (b[i] - b[i - 1]);
		for(int j = 0; j < n; j++) {
			ll x = a[i][j]; 
			c[i] -= x * x; 
			x += d; 
			c[i] += x * x; 
			ll fix = 0; 
			bool o = 1; 
			for(int k = 1; k + 1 < m; k++) {
				ll p = c[k] - c[k - 1], q = c[k + 1] - c[k];
				if(k == 1) fix = q - p; 
				else if(q - p != fix) o = 0; 
			}
			if(o) {
				cout << i << ' ' << x << '\n';
				exit(0);
			}
			c[i] -= x * x;
			x -= d;
			c[i] += x * x; 
		}
	}
	return 0; 
}