#include <bits/stdc++.h>

using namespace std;
typedef long long LL;
const int NMAX = 1000;

int mat[NMAX + 5][NMAX + 5], sumMat[NMAX + 5];

LL sumSquared(int lin, int k)
{
    LL ans = 0;

    for(int j = 1; j <= k; j++)
        ans += 1LL * mat[lin][j] * mat[lin][j];

    return ans;
}

bool verificare(int lin, int k, LL diffABC)
{
    LL A = sumSquared(lin, k), B = sumSquared(lin - 1, k), C = sumSquared(lin + 1, k);

    return (B + C - 2 * A == diffABC);
}

int main()
{
    int m, k;

    cin >> m >> k;

    swap(m, k);

    for(int i = 1; i <= m; i++)
        for(int j = 1; j <= k; j++)
            cin >> mat[i][j];

    for(int i = 1; i <= m; i++)
    {
        int sum = 0;

        for(int j = 1; j <= k; j++)
            sum += mat[i][j];

        sumMat[i] = sum;
    }

    int lin = 0, diff = 0;

    for(int i = 2; i < m - 1; i++)
    {
        int diff1 = sumMat[i] - sumMat[i - 1];
        int diff2 = sumMat[i + 1] - sumMat[i];
        int diff3 = sumMat[i + 2] - sumMat[i + 1];

        if(diff1 != diff2 && diff1 != diff3 && diff2 + diff3 == 2 * diff1)
        {
            lin = i + 1;
            diff = diff1 - diff2;
        }
    }

    if(lin == 0)
    {
        int diff1 = sumMat[2] - sumMat[1];
        int diff2 = sumMat[3] - sumMat[2];
        int diff3 = sumMat[4] - sumMat[3];

        if(diff1 != diff2 && diff2 == diff3)
        {
            lin = 1;
            diff = diff1 - diff2;
        }
        else
        {
            lin = 2;
            diff = diff3 - diff1;
        }
    }

    LL diffABC = 0;
    if(lin > 3)
    {
        LL A = sumSquared(2, k), B = sumSquared(1, k), C = sumSquared(3, k);

        diffABC = B + C - 2 * A;
    }
    else
    {
        LL A = sumSquared(6, k), B = sumSquared(5, k), C = sumSquared(7, k);

        diffABC = B + C - 2 * A;
    }

    int gasit = 0;
    for(int j = 1; !gasit && j <= k; j++)
    {
        mat[lin][j] += diff;

        if(verificare(lin, k, diffABC))
            gasit = mat[lin][j];

        mat[lin][j] -= diff;
    }

    cout << lin - 1 << " " << gasit;
    cout.flush();

    return 0;
}
