// https://codeforces.com/contest/1545/problem/D

#include <bits/stdc++.h>
using namespace std;

constexpr int N = 1111;
int n, k, a[N][N];

int dt, dtv;

void init() {
    for (int i = 0; i < k; ++i) {
        for (int j = 0; j < n; ++j) cin >> a[i][j];
    }
}

void ans(int t, int tv) {
    cout << t << " " << tv << endl;
}

int sm[N];
int64_t sm2[N];

int v[N];

void work() {
    cin >> n >> k;
    init();
    for (int i = 0; i < k; ++i) {
        sm[i] = sm2[i] = 0;
        for (int j = 0; j < n; ++j) {
            sm[i] += a[i][j];
            sm2[i] += a[i][j] * (int64_t)a[i][j];
        }
    }

    int tt = -1, tsm = -1;
    for (int t = 0; t + 2 < k; ++t) {
        if (sm[t] + sm[t + 2] != 2 * sm[t + 1]) {
            if (t == 0) {
                for (int t2 = 1; t2 < k + 2; ++t2)
                    if (sm[t2] + sm[t2 + 2] == 2 * sm[t2 + 1]) {
                        tt = t2 - 1;
                        tsm = 2 * sm[t2] - sm[t2 + 1];
                        break;
                    }
            } else {
                tt = t + 2;
                tsm = 2 * sm[t + 1] - sm[t];
            }
            break;
        }
    }
    assert(tt >= 0 && tsm >= 0);
    // it's row tt!

    int64_t dtsm = tsm - sm[tt];
    sm[tt] = tsm;
    // cerr << "t=" << att << endl;

    int h = 1;
    if (tt < 3) h = tt + 2;
    int64_t dsm2 = sm2[h + 1] - 2 * sm2[h] + sm2[h - 1];
    // for (int i = 0; i < k; ++i) cerr << i << ": " << sm[i] << " " << sm2[i] << endl;

    int64_t tsm2;
    if (tt < 3) {
        tsm2 = sm2[tt + 1] - (sm2[tt + 2] - sm2[tt + 1] - dsm2);
    } else {
        tsm2 = sm2[tt - 1] + (sm2[tt - 1] - sm2[tt - 2] + dsm2);
    }
    int64_t dtsm2 = tsm2 - sm2[tt];
    sm2[tt] = tsm2;

    assert((dtsm2 - dtsm * dtsm) % (2 * dtsm) == 0);
    int64_t tcrd = (dtsm2 - dtsm * dtsm) / 2 / dtsm;
    ans(tt, tcrd + dtsm);
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    srand(time(0));
    int tc = 1;
    //**/ cin >> tc;
    while (tc--) work();
    return 0;
}