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

long long a[1005][1005];
long long s[1005], s2[1005];

// Solve: (always has unique solution)
// ax + by = c
// dx + ey = f
// adx + bdy = cd
// adx + aey = af
// y = (cd - af) / (bd - ae)
array<long long, 2> systemEq(long long a, long long b, long long c, long long d, long long e, long long f) {
    long long y = (c * d - a * f) / (b * d - a * e);
    long long x = (b * f - c * e) / (b * d - a * e);
    return {x, y};
}

int main() {
    // freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(NULL);

    int n, k;
    cin >> n >> k;

    for (int i = 0; i < k; i++) {
        for (int j = 1; j <= n; j++) {
            cin >> a[i][j];
            s[i] += a[i][j];
            s2[i] += a[i][j] * a[i][j];
        }
    }

    // s[k - 1] = sum(x) + sum(v) * (k - 1) = s[0] + ...
    long long sumV = (s[k - 1] - s[0]) / (k - 1);

    long long time = 0;
    for (int i = 1; i < k - 1; i++) {
        if (s[i] != s[0] + i * sumV) {
            time = i;
        }
    }

    assert(time);

    // suppose new = old + z
    long long z = s[time] - (s[0] + time * sumV);

    // s2[i] = s2[0] + 2 * i * sum(xv) + i^2 * sum(v^2)
    int u = 1;
    if (time == 1) u = 2;

    auto p = systemEq(2 * u, u * u, s2[u] - s2[0], 2 * (k - 1), (k - 1) * (k - 1), s2[k - 1] - s2[0]);
    long long sumXV = p[0], sumV2 = p[1];

    // s2[time] = s2_old[time] + z^2 + 2z * old
    long long s2Old = s2[0] + 2 * time * sumXV + time * time * sumV2;
    long long res = (s2[time] - s2Old - z * z) / (2 * z);

    cout << time << " " << res << endl;

    return 0;
}