//μ's forever
#include <bits/stdc++.h>
#define N 1005
#define ll long long
//#define getchar nc
using namespace std;
inline char nc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline int read()
{
    register int x=0,f=1;register char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
    return x*f;
}
inline void write(register int x)
{
    if(!x)putchar('0');if(x<0)x=-x,putchar('-');
    static int sta[20];register int tot=0;
    while(x)sta[tot++]=x%10,x/=10;
    while(tot)putchar(sta[--tot]+48);
}
int n,k,sv,val[N][N],sum[N],ansx,ansy,deltav;
ll sv2,sum2[N],org;
map<int,int> mp;
int main()
{
    n=read(),k=read();
    for(int i=1;i<=k;++i){
        for(int j=1;j<=n;++j)
            val[i][j]=read(),sum[i]+=val[i][j],sum2[i]+=1ll*val[i][j]*val[i][j];
    }
    for(int i=2;i<=k;++i){
        ++mp[sum[i]-sum[i-1]];
        if(mp[sum[i]-sum[i-1]]>=2) sv=sum[i]-sum[i-1];
    }
    if(sum[2]-sum[1]!=sv&&sum[3]-sum[2]==sv) ansx=1,deltav=sv-sum[2]+sum[1];
    else if(sum[k]-sum[k-1]!=sv&&sum[k-1]-sum[k-2]==sv) ansx=k,deltav=sv-sum[k]+sum[k-1];
    else{
        for(int i=2;i<k;++i)
            if(sum[i]-sum[i-1]!=sv&&sum[i+1]-sum[i]!=sv)
                ansx=i,deltav=sv-sum[i]+sum[i-1];
    }
    // cerr<<deltav<<endl;
    for(int i=1;i<=k-2;++i){
        if(i==ansx||i+1==ansx||i+2==ansx) continue;
        sv2=sum2[i]+sum2[i+2]-2ll*sum2[i+1];
    }
    // for(int i=2;i<=k;++i) printf("%d\n",sum2[i]-sum2[i-1]);
    // if(ansx<=k+2) org=2ll*sum2[ansx+1]-sum[ansx+2]+sv2;
    // else org=2ll*sum2[ansx-1]-sum[ansx-2]+sv2;
    if(ansx==1) org=sum2[2]-(sum2[3]-sum2[2]-sv2);
    else if(ansx==2) org=sum2[3]-(sum2[4]-sum2[3]-sv2);
    else org=sum2[ansx-1]+sum2[2]-sum2[1]+1ll*(ansx-2)*sv2;
    // cerr<<sum2[ansx]<<" "<<org<<endl;
    for(int i=1;i<=n;++i)
        if(1ll*val[ansx][i]*val[ansx][i]-1ll*(val[ansx][i]+deltav)*(val[ansx][i]+deltav)==sum2[ansx]-org)
            ansy=val[ansx][i]+deltav;
    printf("%d %d\n",ansx-1,ansy);
    fflush(stdout);
    return 0;
}
