#include <bits/stdc++.h>
#define ll long long 
#define INF INT_MAX
#define pii pair<int,int>
using namespace std;

const int maxn=1e3+10;
const int mod=998244353;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll N,K;
    cin>>N>>K;
    vector<vector<ll>> p(maxn);
    vector<ll> s1(maxn,0);
    vector<ll> s2(maxn,0);
    ll tem;
    for(int i=0;i<K;i++){
        for(int j=0;j<N;j++){
            cin>>tem;
            p[i].push_back(tem);
            s1[i]+=tem;
            s2[i]+=(tem*tem);
        }
    }
    map<ll,ll> cnt;
    map<ll,ll> cnt2;
    ll tem2;

    for(int i=1;i<=6;i++){
        tem=s1[i]-s1[i-1];
        tem2=s2[i-1]+s2[i+1]-2*s2[i];
        if(cnt.find(tem)==cnt.end()){
            cnt[tem]=0;
        }
        else
            cnt[tem]++;
        if(i!=6){
            if(cnt2.find(tem2)==cnt2.end()){
                cnt2[tem2]=0;
            }
            else
                cnt2[tem2]++;
        }
    }
    ll d,sq;
    auto it=cnt.begin();
    if(it->second>=3)
    d=it->first;
    else{
        it++;
        d=it->first;
    }
    auto it2=cnt2.begin();
    if(it2->second>=2)
    sq=it2->first;
    else{
        it2++;
        sq=it2->first;
    }
    //cout<<sq<<'\n';
    ll er;
    for(int i=0;i<K-1;i++){
        if(s1[i+1]-s1[i]!=d){
            er=i+1;
            break;
        }
    }
    if(er==1 && s1[2]-s1[1]==d){
        er=0;
    }
    ll dif,dif2;
    tem=0;
    for(int i=0;i<N;i++){
        tem+=(p[er][i]*p[er][i]);
    }
    //cout<<tem<<'\n';
    if(er==0)
    dif=s1[er+1]-d-s1[er];
    else
    dif=s1[er-1]+d-s1[er];
    //cout<<dif<<'\n';
    ll ans=0;
    for(int i=0;i<N;i++){
        if(er<=K-3){
            if(s2[er+2]-2*s2[er+1]+s2[er]-p[er][i]*p[er][i]+(p[er][i]+dif)*(p[er][i]+dif)==sq){
                ans=p[er][i]+dif;
                break;
            }
        }
        else{
            if(s2[er-2]-2*s2[er-1]+s2[er]-p[er][i]*p[er][i]+(p[er][i]+dif)*(p[er][i]+dif)==sq){
                ans=p[er][i]+dif;
                break;
            }
        }
    }
    cout<<er<<" "<<ans<<'\n';
}