#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std ;
#define ll long long
const ll N = 2000 ;
ll mod = 998244353 ;
ll a[ N ][ N ] , //原数据
c[ N ]; // 隔行位置和
int main(){
    ll n , m ;
    cin >> n >> m ;
    for( int i = 0 ; i < m ; i ++ ){
        for( int j = 1 ; j <= n ; j ++ ){
            cin >> a[ i ][ j ] ;
            c[ i ] += a[ i ][ j ] ;
        }
    }
    ll x = ( c[m-1] - c[0] )/( m - 1 ) ,//确定等差数列公差
     y , ans1 , ans2 ;
    for( int i = 1 ; i < m ; i ++ ){
        if( (c[i]-c[0])!= x*i ){
            ans1 = i ; // 找到有误的一行
            y = c[ i ] - c[ 0 ] - x*i ; //找到误差值
            break ;
        }
    }
    for( int i = 1 ; i < m - 1 ; i ++ ){
        if( i-1 != ans1 && i != ans1 && i+1 != ans1 ){//找到正常的三行
            x = 0 ;
            for( int j = 1 ; j <= n ; j ++ ){
                x += a[i-1][j]*a[i-1][j]+a[i+1][j]*a[i+1][j]-a[i][j]*a[i][j]*2;
                //计算2Σvi2
            }
            break ;
        }
    }
    ll t = 0 , s = 0 ;
    for( int j = 1 ; j <= n ; j ++ ){
        s += a[ans1-1][j]*a[ans1-1][j] + a[ans1+1][j]*a[ans1+1][j];//sum2[y-1]+sum2[y+1]
        t += a[ans1][j]*a[ans1][j]*2 ;//sum2[y]
    }
    s -= x ;//s=2sum2[y]
    // y = 误差值
    for( int j = 1 ; j <= n ; j ++ ){
        ll temp = t - a[ans1][j]*a[ans1][j]*2 + (a[ans1][j]-y)*(a[ans1][j]-y)*2 ;
        //枚举误差点
        if( temp == s ){
            ans2 = a[ans1][j] -y ;//计算正确的值
            break ;
        }
    }
    cout << ans1 << " " << ans2 ;
    return 0 ;

}
