#include <bits/stdc++.h>
using namespace std;
#define int long long
void read (int &x) {
    char ch = getchar(); int f = 0; x = 0;
    while (!isdigit(ch)) { if (ch == '-') f = 1; ch = getchar(); }
    while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
    if (f) x = -x;
} const int N = 1024;
int m, k, y, p, a[N][N], s[N], pp[N], S[N], ss[N];
map<int, int> mp;
void print (int x, int y) {
    printf ("%lld %lld\n", x, y); fflush (stdout);
}
int check () {
    for (int i = 2; i < k; ++i) ss[i] = S[i + 1] + S[i - 1] - 2 * S[i];
    for (int i = 3; i < k; ++i) if (ss[i] != ss[i - 1]) return 0; return 1;
}
signed main() {
    read (m), read (k);
    for (int i = 1; i <= k; ++i)
        for (int j = 1; j <= m; ++j)
            read (a[i][j]), s[i] += a[i][j], S[i] += a[i][j] * a[i][j];
    for (int i = 1; i < k; ++i) pp[i] = s[i + 1] - s[i];
    // for (int i = 1; i < k; ++i) printf ("%lld ", pp[i]); puts ("");
    for (int i = 1; i < k; ++i) ++mp[pp[i]];
    int mx = 0, val = 0;
    for (auto i : mp) if (i.second > mx) mx = i.second, val = i.first;
    for (int i = 1; i < k; ++i)
        if (pp[i] != val) {
            if (i == 1) y = pp[2] == val ? 1 : 2;
            else y = i + 1; break;
        }
    for (int i = 1, tmp; i <= m; ++i) {
        if (y < k) tmp = s[y + 1] - val - s[y];
        else tmp = s[y - 1] + val - s[y];
        S[y] += 2 * tmp * a[y][i] + tmp * tmp;
        if (check ()) { print (y - 1, a[y][i] + tmp); break; }
        S[y] -= 2 * tmp * a[y][i] + tmp * tmp;
    }
    return 0;
}
