#include <iostream>
#include <vector>
#include <random>

typedef unsigned long long ull;
typedef signed long long sll;
using namespace std;

size_t vmin(vector<size_t>& values) {
    size_t ans = -1;
    for (auto& v : values) ans = min(ans, v);
    return ans;
}
size_t vmax(vector<size_t>& values) {
    size_t ans = 0;
    for (auto& v : values) ans = max(ans, v);
    return ans;
}

size_t first_incorrect, last_incorrect;
vector<size_t> coord_sums, coord_sq_sums;
vector<vector<size_t>> shuffled_positions;
size_t m, k, i, j, t, correct_coef, d, cur_sq_sum, cur_coef;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);

    cin >> m >> k;
    shuffled_positions.resize(k);
    coord_sums.reserve(k); coord_sq_sums.reserve(k);
    for (auto& row : shuffled_positions) {
        row.resize(m);
        coord_sums.push_back(0);
        coord_sq_sums.push_back(0);
        for (auto& v : row) {
            cin >> v;
            coord_sums.back() += v;
            coord_sq_sums.back() += v * v;
        }
    }

    first_incorrect = last_incorrect = 0;

    for (i = 1; i < k - 1; i++) {
        if (coord_sums[i + 1] - coord_sums[i - 0] !=
            coord_sums[i - 0] - coord_sums[i - 1]) {
            if (!first_incorrect) first_incorrect = i;
            last_incorrect = i;
        }
    }

    if (first_incorrect == 1) {
        j = last_incorrect - 1;
    } else if (last_incorrect == k - 2) {
        j = first_incorrect + 1;
    } else {
        j = first_incorrect + 1;
    }
    cout << j << " ";

    if (j < 3) {
        t = j + 1;
    } else {
        t = 0;
    }
    correct_coef = coord_sq_sums[t] + coord_sq_sums[t + 2]
                 - 2 * coord_sq_sums[t + 1];

    d = (coord_sums[t + 1] - coord_sums[t]) - (coord_sums[j + 1] - coord_sums[j]);
    #ifndef ONLINE_JUDGE
    cout << "[d=" << d << ", cc=" << correct_coef << "]";
    #endif // ONLINE_JUDGE


    for (i = 0; i < m; i++) {
        cur_sq_sum = coord_sq_sums[j];
        cur_sq_sum -= shuffled_positions[j][i] * shuffled_positions[j][i];
        cur_sq_sum += (shuffled_positions[j][i] - d) * (shuffled_positions[j][i] - d);

        cur_coef = coord_sq_sums[j - 1] + coord_sq_sums[j + 1] - 2 * cur_sq_sum;

        #ifndef ONLINE_JUDGE
        cout << " [" << shuffled_positions[j][i] - d << "->" << shuffled_positions[j][i]
             << " csqs=" << cur_sq_sum << " cc=" << cur_coef << "]";
        #endif

        if (cur_coef == correct_coef) {
            cout << shuffled_positions[j][i] - d << endl;
            return 0;
        }
    }
    cout << 0 << endl;

    return 0;
}
