#include <iostream>
#include <vector>

using namespace std;

int main() {
    int m,k; cin >> m >> k;
    vector<long long> sums = vector<long long>(k,0);
    vector<long long> sumOfSquares = vector<long long>(k,0);
    for (int i=0; i<k; i++) {
        for (int j=0; j<m; j++) {
            int temp; cin >> temp; 
            sums[i] += temp;
            sumOfSquares[i] += temp*temp;
        }
    }
    long long a=sums[1]-sums[0];
    int j=0;
    while (sums[j+2]-sums[j+1] != a) {
        a = sums[j+2]-sums[j+1];
        j++;
    }
    long long b = sums[j]-j*a;
    int t = 0;
    while (sums[t] == a*t+b) {
        t++;
    }
    j = t>=3 ? 0 : 3;
    long long c = (sumOfSquares[j] + sumOfSquares[j+2] - 2*sumOfSquares[j+1])/2;
    long long d = sumOfSquares[j+1]-sumOfSquares[j]-2*c*j-c;
    long long e = sumOfSquares[j]-c*j*j-d*j;
    long long diff1 = sums[t]-a*t-b;
    long long diff2 = sumOfSquares[t]-c*t*t-d*t-e;
    long long original = (diff2-diff1*diff1)/(2*diff1);
    cout << t << ' ' << original << '\n';
}
