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

#define sz(s) (int)s.size()
#define f first
#define s second
#define pb push_back
#define all(s) s.begin(), s.end()

#define vi vector<int>
#define vvi vector<vi>

#define ll long long
#define vll vector<ll>

#define ii pair<int, int>
#define vii vector<ii>
#define vvii vector<vii>

const int INF = 1e9 + 7;
const int mod = 1e9 + 7;
const int N = 1e6 + 7;
const int T = 1 << 20;
#define ld long double


ll suma(vi & tab){
    return accumulate(all(tab), 0ll);
}

ll suma2(vi & tab){
    ll ret = 0;
    for(auto & u : tab)
        ret += 1 * u * u;
    return ret;
}

int n, m;
vvi tab;

ll v2(vi & a, vi & b, vi & c){
    return suma2(a) + suma2(c) - 2 * suma2(b);
}
    
bool check_hasz(int pocz, int kon){
    ll HASZ = v2(tab[pocz], tab[pocz + 1], tab[pocz + 2]);
    for(int i = pocz + 1; i <= kon - 2; i++)
        if(v2(tab[i], tab[i + 1], tab[i + 2]) != HASZ)
            return false;
    return true;
}

void wypisz(vvi vec){
    for(auto & u : vec){
        for(auto & v : u){
            cout << v << ' ';
        }
        cout << endl;
    }
    cout << endl;
}

void solve(){
    cin >> m >> n;
    tab = vvi(n, vi(m));

    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
            cin >> tab[i][j];

    // wypisz(tab);

    for(int i = 0; i < n - 2; i++){
        int pom = suma(tab[i]) + suma(tab[i + 2]) - 2 * suma(tab[i + 1]);
        // cout << "POM " << pom << endl;
        if(pom != 0){
            for(int j = i; j <= i + 2; j++){
                for(int a = 0; a < m; a++){
                    int org = tab[j][a];
                    // cout << i << ' ' << j << ' ' << a << endl;

                    // wypisz(tab);

                    int val = (j == i + 1 ? tab[j][a] + pom / 2 : tab[j][a] - pom);
                    tab[j][a] = val;
                    bool ok = suma(tab[i]) + suma(tab[i + 2]) == 2 * suma(tab[i + 1]);
                    assert(j == i + 1 or ok);
                    
                    if(ok and check_hasz(max(0, i - 5), min(n - 1, i + 5))){
                        cout << j << ' ' << val << endl;
                        exit(0);
                    }
                    tab[j][a] = org;
                }
            }
        }
    }
    assert(false);
}

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);

    int test = 1;
    // cin >> test;

    for(int i = 0; i < test; i++)
        solve();
}