#include <bits/stdc++.h>
using namespace std;
#define INF 100010001
#define mod 1000000007

typedef long long int ll;
typedef unsigned long long llu;
typedef long double ld;

#define F first
#define S second
#define pb push_back
#define mk make_pair
#define pp pop_back
#define len(vale) strlen(vale)
#define sz(vale) vale.size()
#define sq(A) ((A)*(A))
#define pc putchar
#define gc getchar
#define f(i12,fa,fb) for(i12=fa;i12<fb;i12++)
#define fd(i12,fa,fb) for(i12=fa;i12>fb;i12--)
//#define debug(args...) do {cerr << #args << ": "; DBG,args; cerr << endl;} while(0)
#define forit(it,S) for(__typeof((S).begin()) it = (S).begin(); it != (S).end(); it++)
#define bits(vale) __builtin_popcount(vale)

#define set1(array,val,sz) for(int i13=0;i13<sz;i13++)array[i13]=val;
#define set2(array,val,sz) for(int i13=0;i13<sz;i13++)for(int i14=0;i14<sz;i14++)array[i13][i14]=val;

#define all(a) a.begin(),a.end()
#define lb(a,x) (lower_bound(all(a),x)-a.begin())
#define ub(a,x) (upper_bound(all(a),x)-a.begin())

#define exectime() cout<<"execution time ="<<(double)(clock()- tStart)/CLOCKS_PER_SEC<<endl;

#define TRACE
#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

// IO
#define si(vale) scanf("%d",&vale)
#define pi(vale) printf("%d\n",vale)
#define sl(vale) scanf("%lld",&vale)
#define pl(vale) printf("%lld\n",vale)
#define ss(vale) scanf("%s",vale)
#define ps(vale) printf("%s\n",vale)
#define sld(vale) cin>>vale
#define pld(vale) cout<<std::setprecision(15)<< fixed <<vale <<endl
//

#define tcs() int testcase; si(testcase);while(testcase--)
void io()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
}

typedef pair<int,int> pr;
typedef vector<int> vt;

bool deg=false;
const int N=111;
int a[N][N]={0};

int main(){
    //io();
    //clock_t tStart = clock();
    int i,j,n,m;
    si(n),si(m);
    int cd[N]={0};
    f(i,1,m+1)
    {	int mx=0;
    	f(j,1,n+1)
    	{
    		si(a[i][j]);
    	}
    	a[i][0]=-1;
    	f(j,1,n+1)
    	{
    		if(a[i][mx]<a[i][j])
    			mx=j;
    	}
    	//trace1(mx);
    	//f(j,1,m+1)
    	//	if(a[i][mx]==a[i][j])
    	//		cd[j]++;
    	cd[mx]++;
    }
    int mx=0;
    cd[0]=-1;
    f(i,1,n+1)
    {
    	if(cd[mx]<cd[i])
    		mx=i;
    }
    pi(mx);
    //exectime();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define INF 100010001
#define mod 1000000007

typedef long long int ll;
typedef unsigned long long llu;
typedef long double ld;

#define F first
#define S second
#define pb push_back
#define mk make_pair
#define pp pop_back
#define len(vale) strlen(vale)
#define sz(vale) vale.size()
#define sq(A) ((A)*(A))
#define pc putchar
#define gc getchar
#define f(i12,fa,fb) for(i12=fa;i12<fb;i12++)
#define fd(i12,fa,fb) for(i12=fa;i12>fb;i12--)
//#define debug(args...) do {cerr << #args << ": "; DBG,args; cerr << endl;} while(0)
#define forit(it,S) for(__typeof((S).begin()) it = (S).begin(); it != (S).end(); it++)
#define bits(vale) __builtin_popcount(vale)

#define set1(array,val,sz) for(int i13=0;i13<sz;i13++)array[i13]=val;
#define set2(array,val,sz) for(int i13=0;i13<sz;i13++)for(int i14=0;i14<sz;i14++)array[i13][i14]=val;

#define all(a) a.begin(),a.end()
#define lb(a,x) (lower_bound(all(a),x)-a.begin())
#define ub(a,x) (upper_bound(all(a),x)-a.begin())

#define exectime() cout<<"execution time ="<<(double)(clock()- tStart)/CLOCKS_PER_SEC<<endl;

#define TRACE
#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

// IO
#define si(vale) scanf("%d",&vale)
#define pi(vale) printf("%d\n",vale)
#define sl(vale) scanf("%lld",&vale)
#define pl(vale) printf("%lld\n",vale)
#define ss(vale) scanf("%s",vale)
#define ps(vale) printf("%s\n",vale)
#define sld(vale) cin>>vale
#define pld(vale) cout<<std::setprecision(15)<< fixed <<vale <<endl
//

#define tcs() int testcase; si(testcase);while(testcase--)
void io()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
}

typedef pair<int,int> pr;
typedef vector<int> vt;

bool deg=false;
const int N=111;
int a[N][N]={0};

int main(){
    //io();
    //clock_t tStart = clock();
    int i,j,n,m;
    si(n),si(m);
    int c[N];
    f(i,1,n+1)
    {	int mx=0;
    	f(j,1,m+1)
    	{
    		si(a[i][j]);
    	}
    	f(j,1,m+1)
    	{
    		if(a[i][mx]<a[i][j])
    			mx=j;
    	}
    	c[i]=mx;
    }
    int cd[N]={0};
    f(i,1,n+1)
    {
    	cd[c[i]]++;
    }
    int mx=0;
    f(i,1,n+1)
    {
    	if(cd[mx]<cd[i])
    		mx=i;
    }
    pi(mx);
    //exectime();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define INF 100010001
#define mod 1000000007

typedef long long int ll;
typedef unsigned long long llu;
typedef long double ld;

#define F first
#define S second
#define pb push_back
#define mk make_pair
#define pp pop_back
#define len(vale) strlen(vale)
#define sz(vale) vale.size()
#define sq(A) ((A)*(A))
#define pc putchar
#define gc getchar
#define f(i12,fa,fb) for(i12=fa;i12<fb;i12++)
#define fd(i12,fa,fb) for(i12=fa;i12>fb;i12--)
//#define debug(args...) do {cerr << #args << ": "; DBG,args; cerr << endl;} while(0)
#define forit(it,S) for(__typeof((S).begin()) it = (S).begin(); it != (S).end(); it++)
#define bits(vale) __builtin_popcount(vale)

#define set1(array,val,sz) for(int i13=0;i13<sz;i13++)array[i13]=val;
#define set2(array,val,sz) for(int i13=0;i13<sz;i13++)for(int i14=0;i14<sz;i14++)array[i13][i14]=val;

#define all(a) a.begin(),a.end()
#define lb(a,x) (lower_bound(all(a),x)-a.begin())
#define ub(a,x) (upper_bound(all(a),x)-a.begin())

#define exectime() cout<<"execution time ="<<(double)(clock()- tStart)/CLOCKS_PER_SEC<<endl;

#define TRACE
#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

// IO
#define si(vale) scanf("%d",&vale)
#define pi(vale) printf("%d\n",vale)
#define sl(vale) scanf("%lld",&vale)
#define pl(vale) printf("%lld\n",vale)
#define ss(vale) scanf("%s",vale)
#define ps(vale) printf("%s\n",vale)
#define sld(vale) cin>>vale
#define pld(vale) cout<<std::setprecision(15)<< fixed <<vale <<endl
//

#define tcs() int testcase; si(testcase);while(testcase--)
void io()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
}

typedef pair<int,int> pr;
typedef vector<int> vt;

bool deg=false;
const int N=111;
int a[N][N]={0};

int main(){
    //io();
    //clock_t tStart = clock();
    int i,j,n,m;
    si(m),si(n);
    int c[N];
    int cd[N]={0};
    f(i,1,n+1)
    {	int mx=0;
    	f(j,1,m+1)
    	{
    		si(a[i][j]);
    	}
    	a[i][0]=-1;
    	f(j,1,m+1)
    	{
    		if(a[i][mx]<a[i][j])
    			mx=j;
    	}
    	//f(j,1,m+1)
    	//	if(a[i][mx]==a[i][j])
    	//		cd[j]++;
    	cd[mx]++;
    }
    int mx=0;
    cd[0]=-1;
    f(i,1,n+1)
    {
    	if(cd[mx]<cd[i])
    		mx=i;
    }
    pi(mx);
    //exectime();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define INF 100010001
#define mod 1000000007

typedef long long int ll;
typedef unsigned long long llu;
typedef long double ld;

#define F first
#define S second
#define pb push_back
#define mk make_pair
#define pp pop_back
#define len(vale) strlen(vale)
#define sz(vale) vale.size()
#define sq(A) ((A)*(A))
#define pc putchar
#define gc getchar
#define f(i12,fa,fb) for(i12=fa;i12<fb;i12++)
#define fd(i12,fa,fb) for(i12=fa;i12>fb;i12--)
//#define debug(args...) do {cerr << #args << ": "; DBG,args; cerr << endl;} while(0)
#define forit(it,S) for(__typeof((S).begin()) it = (S).begin(); it != (S).end(); it++)
#define bits(vale) __builtin_popcount(vale)

#define set1(array,val,sz) for(int i13=0;i13<sz;i13++)array[i13]=val;
#define set2(array,val,sz) for(int i13=0;i13<sz;i13++)for(int i14=0;i14<sz;i14++)array[i13][i14]=val;

#define all(a) a.begin(),a.end()
#define lb(a,x) (lower_bound(all(a),x)-a.begin())
#define ub(a,x) (upper_bound(all(a),x)-a.begin())

#define exectime() cout<<"execution time ="<<(double)(clock()- tStart)/CLOCKS_PER_SEC<<endl;

#define TRACE
#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

// IO
#define si(vale) scanf("%d",&vale)
#define pi(vale) printf("%d\n",vale)
#define sl(vale) scanf("%lld",&vale)
#define pl(vale) printf("%lld\n",vale)
#define ss(vale) scanf("%s",vale)
#define ps(vale) printf("%s\n",vale)
#define sld(vale) cin>>vale
#define pld(vale) cout<<std::setprecision(15)<< fixed <<vale <<endl
//

#define tcs() int testcase; si(testcase);while(testcase--)
void io()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
}

typedef pair<int,int> pr;
typedef vector<int> vt;

bool deg=false;
const int N=111;
int a[N][N]={0};

int main(){
    //io();
    //clock_t tStart = clock();
    int i,j,n,m;
    si(n),si(m);
    int cd[N]={0};
    f(i,1,m+1)
    {	int mx=0;
    	f(j,1,n+1)
    	{
    		si(a[i][j]);
    	}
    	a[i][0]=-1;
    	f(j,1,m+1)
    	{
    		if(a[i][mx]<a[i][j])
    			mx=j;
    	}
    	//trace1(mx);
    	//f(j,1,m+1)
    	//	if(a[i][mx]==a[i][j])
    	//		cd[j]++;
    	cd[mx]++;
    }
    int mx=0;
    cd[0]=-1;
    f(i,1,n+1)
    {
    	if(cd[mx]<cd[i])
    		mx=i;
    }
    pi(mx);
    //exectime();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define INF 100010001
#define mod 1000000007

typedef long long int ll;
typedef unsigned long long llu;
typedef long double ld;

#define F first
#define S second
#define pb push_back
#define mk make_pair
#define pp pop_back
#define len(vale) strlen(vale)
#define sz(vale) vale.size()
#define sq(A) ((A)*(A))
#define pc putchar
#define gc getchar
#define f(i12,fa,fb) for(i12=fa;i12<fb;i12++)
#define fd(i12,fa,fb) for(i12=fa;i12>fb;i12--)
//#define debug(args...) do {cerr << #args << ": "; DBG,args; cerr << endl;} while(0)
#define forit(it,S) for(__typeof((S).begin()) it = (S).begin(); it != (S).end(); it++)
#define bits(vale) __builtin_popcount(vale)

#define set1(array,val,sz) for(int i13=0;i13<sz;i13++)array[i13]=val;
#define set2(array,val,sz) for(int i13=0;i13<sz;i13++)for(int i14=0;i14<sz;i14++)array[i13][i14]=val;

#define all(a) a.begin(),a.end()
#define lb(a,x) (lower_bound(all(a),x)-a.begin())
#define ub(a,x) (upper_bound(all(a),x)-a.begin())

#define exectime() cout<<"execution time ="<<(double)(clock()- tStart)/CLOCKS_PER_SEC<<endl;

#define TRACE
#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

// IO
#define si(vale) scanf("%d",&vale)
#define pi(vale) printf("%d\n",vale)
#define sl(vale) scanf("%lld",&vale)
#define pl(vale) printf("%lld\n",vale)
#define ss(vale) scanf("%s",vale)
#define ps(vale) printf("%s\n",vale)
#define sld(vale) cin>>vale
#define pld(vale) cout<<std::setprecision(15)<< fixed <<vale <<endl
//

#define tcs() int testcase; si(testcase);while(testcase--)
void io()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
}

typedef pair<int,int> pr;
typedef vector<int> vt;

bool deg=false;
const int N=111;
int a[N][N]={0};

int main(){
    //io();
    //clock_t tStart = clock();
    int i,j,n,m;
    si(m),si(n);
    int c[N];
    int cd[N]={0};
    f(i,1,n+1)
    {	int mx=0;
    	f(j,1,m+1)
    	{
    		si(a[i][j]);
    	}
    	f(j,1,m+1)
    	{
    		if(a[i][mx]<a[i][j])
    			mx=j;
    	}
    	cd[mx]++;
    }
    int mx=0;
    f(i,1,n+1)
    {
    	if(cd[mx]<cd[i])
    		mx=i;
    }
    pi(mx);
    //exectime();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define INF 100010001
#define mod 1000000007

typedef long long int ll;
typedef unsigned long long llu;
typedef long double ld;

#define F first
#define S second
#define pb push_back
#define mk make_pair
#define pp pop_back
#define len(vale) strlen(vale)
#define sz(vale) vale.size()
#define sq(A) ((A)*(A))
#define pc putchar
#define gc getchar
#define f(i12,fa,fb) for(i12=fa;i12<fb;i12++)
#define fd(i12,fa,fb) for(i12=fa;i12>fb;i12--)
//#define debug(args...) do {cerr << #args << ": "; DBG,args; cerr << endl;} while(0)
#define forit(it,S) for(__typeof((S).begin()) it = (S).begin(); it != (S).end(); it++)
#define bits(vale) __builtin_popcount(vale)

#define set1(array,val,sz) for(int i13=0;i13<sz;i13++)array[i13]=val;
#define set2(array,val,sz) for(int i13=0;i13<sz;i13++)for(int i14=0;i14<sz;i14++)array[i13][i14]=val;

#define all(a) a.begin(),a.end()
#define lb(a,x) (lower_bound(all(a),x)-a.begin())
#define ub(a,x) (upper_bound(all(a),x)-a.begin())

#define exectime() cout<<"execution time ="<<(double)(clock()- tStart)/CLOCKS_PER_SEC<<endl;

#define TRACE
#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

// IO
#define si(vale) scanf("%d",&vale)
#define pi(vale) printf("%d\n",vale)
#define sl(vale) scanf("%lld",&vale)
#define pl(vale) printf("%lld\n",vale)
#define ss(vale) scanf("%s",vale)
#define ps(vale) printf("%s\n",vale)
#define sld(vale) cin>>vale
#define pld(vale) cout<<std::setprecision(15)<< fixed <<vale <<endl
//

#define tcs() int testcase; si(testcase);while(testcase--)
void io()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
}

typedef pair<int,int> pr;
typedef vector<int> vt;

bool deg=false;
const int N=111;
int a[N][N]={0};

int main(){
    //io();
    //clock_t tStart = clock();
    int i,j,n,m;
    si(m),si(n);
    int c[N];
    int cd[N]={0};
    f(i,1,n+1)
    {	int mx=0;
    	f(j,1,m+1)
    	{
    		si(a[i][j]);
    	}
    	a[i][0]=-1;
    	f(j,1,m+1)
    	{
    		if(a[i][mx]<a[i][j])
    			mx=j;
    	}
    	//trace1(mx);
    	//f(j,1,m+1)
    	//	if(a[i][mx]==a[i][j])
    	//		cd[j]++;
    	cd[mx]++;
    }
    int mx=0;
    cd[0]=-1;
    f(i,1,n+1)
    {
    	if(cd[mx]<cd[i])
    		mx=i;
    }
    pi(mx);
    //exectime();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define INF 100010001
#define mod 1000000007

typedef long long int ll;
typedef unsigned long long llu;
typedef long double ld;

#define F first
#define S second
#define pb push_back
#define mk make_pair
#define pp pop_back
#define len(vale) strlen(vale)
#define sz(vale) vale.size()
#define sq(A) ((A)*(A))
#define pc putchar
#define gc getchar
#define f(i12,fa,fb) for(i12=fa;i12<fb;i12++)
#define fd(i12,fa,fb) for(i12=fa;i12>fb;i12--)
//#define debug(args...) do {cerr << #args << ": "; DBG,args; cerr << endl;} while(0)
#define forit(it,S) for(__typeof((S).begin()) it = (S).begin(); it != (S).end(); it++)
#define bits(vale) __builtin_popcount(vale)

#define set1(array,val,sz) for(int i13=0;i13<sz;i13++)array[i13]=val;
#define set2(array,val,sz) for(int i13=0;i13<sz;i13++)for(int i14=0;i14<sz;i14++)array[i13][i14]=val;

#define all(a) a.begin(),a.end()
#define lb(a,x) (lower_bound(all(a),x)-a.begin())
#define ub(a,x) (upper_bound(all(a),x)-a.begin())

#define exectime() cout<<"execution time ="<<(double)(clock()- tStart)/CLOCKS_PER_SEC<<endl;

#define TRACE
#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

// IO
#define si(vale) scanf("%d",&vale)
#define pi(vale) printf("%d\n",vale)
#define sl(vale) scanf("%lld",&vale)
#define pl(vale) printf("%lld\n",vale)
#define ss(vale) scanf("%s",vale)
#define ps(vale) printf("%s\n",vale)
#define sld(vale) cin>>vale
#define pld(vale) cout<<std::setprecision(15)<< fixed <<vale <<endl
//

#define tcs() int testcase; si(testcase);while(testcase--)
void io()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
}

typedef pair<int,int> pr;
typedef vector<int> vt;

bool deg=false;
const int N=111;
int a[N][N]={0};

int main(){
    //io();
    //clock_t tStart = clock();
    int i,j,n,m;
    si(m),si(n);
    int cd[N]={0};
    f(i,1,m+1)
    {	int mx=0;
    	f(j,1,n+1)
    	{
    		si(a[i][j]);
    	}
    	a[i][0]=-1;
    	f(j,1,m+1)
    	{
    		if(a[i][mx]<a[i][j])
    			mx=j;
    	}
    	//trace1(mx);
    	//f(j,1,m+1)
    	//	if(a[i][mx]==a[i][j])
    	//		cd[j]++;
    	cd[mx]++;
    }
    int mx=0;
    cd[0]=-1;
    f(i,1,n+1)
    {
    	if(cd[mx]<cd[i])
    		mx=i;
    }
    pi(mx);
    //exectime();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define INF 100010001
#define mod 1000000007

typedef long long int ll;
typedef unsigned long long llu;
typedef long double ld;

#define F first
#define S second
#define pb push_back
#define mk make_pair
#define pp pop_back
#define len(vale) strlen(vale)
#define sz(vale) vale.size()
#define sq(A) ((A)*(A))
#define pc putchar
#define gc getchar
#define f(i12,fa,fb) for(i12=fa;i12<fb;i12++)
#define fd(i12,fa,fb) for(i12=fa;i12>fb;i12--)
//#define debug(args...) do {cerr << #args << ": "; DBG,args; cerr << endl;} while(0)
#define forit(it,S) for(__typeof((S).begin()) it = (S).begin(); it != (S).end(); it++)
#define bits(vale) __builtin_popcount(vale)

#define set1(array,val,sz) for(int i13=0;i13<sz;i13++)array[i13]=val;
#define set2(array,val,sz) for(int i13=0;i13<sz;i13++)for(int i14=0;i14<sz;i14++)array[i13][i14]=val;

#define all(a) a.begin(),a.end()
#define lb(a,x) (lower_bound(all(a),x)-a.begin())
#define ub(a,x) (upper_bound(all(a),x)-a.begin())

#define exectime() cout<<"execution time ="<<(double)(clock()- tStart)/CLOCKS_PER_SEC<<endl;

#define TRACE
#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

// IO
#define si(vale) scanf("%d",&vale)
#define pi(vale) printf("%d\n",vale)
#define sl(vale) scanf("%lld",&vale)
#define pl(vale) printf("%lld\n",vale)
#define ss(vale) scanf("%s",vale)
#define ps(vale) printf("%s\n",vale)
#define sld(vale) cin>>vale
#define pld(vale) cout<<std::setprecision(15)<< fixed <<vale <<endl
//

#define tcs() int testcase; si(testcase);while(testcase--)
void io()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
}

typedef pair<int,int> pr;
typedef vector<int> vt;

bool deg=false;
const int N=111;
int a[N][N]={0};

int main(){
    //io();
    //clock_t tStart = clock();
    int i,j,n,m;
    si(m),si(n);
    int c[N];
    int cd[N]={0};
    f(i,1,n+1)
    {	int mx=0;
    	f(j,1,m+1)
    	{
    		si(a[i][j]);
    	}
    	a[i][0]=-1;
    	f(j,1,m+1)
    	{
    		if(a[i][mx]<a[i][j])
    			mx=j;
    	}
    	//f(j,1,m+1)
    	//	if(a[i][mx]==a[i][j])
    	//		cd[j]++;
    	//cd[mx]++;
    }
    int mx=0;
    cd[0]=-1;
    f(i,1,n+1)
    {
    	if(cd[mx]<cd[i])
    		mx=i;
    }
    pi(mx);
    //exectime();
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll cnt[1000];
int main()
{
    ll n,m,i,j,k,l,r,mx,ans=0;
    cin>>n>>m;
    ll ar[n];
    for(i=0;i<m;i++){
            mx=0;
    for(j=0;j<n;j++){
        cin>>ar[j];
        if(ar[j]>mx)
            mx=ar[j];
        }
        ll t;
    for(k=n-1;k>=0;k--){
        if(ar[k]==mx)
            t=k+1;
    }
    cnt[t]++;
    if(cnt[t]>ans)
        ans=cnt[t];
    }
    for(i=1;i<=n;i++){
       if(ans==cnt[i]){
        cout<<i<<endl;
        return 0;
       }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int cnt[1000];
int main()
{
    long long n,m;
    cin>>n>>m;
    long long arr[m+1][n+1];
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            cin>>arr[i][j];
        }
    }
    int mx=INT_MIN,p=0;
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            if(arr[i][j]>mx){
                mx=arr[i][j];
                p=j+1;
            }
        }
        cnt[p]++;
        mx=0;
    }
    for(int i=1;i<=n;i++){
        if(cnt[i]>mx)
            mx=cnt[i];
            p=i;
    }
    cout<<p<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int cnt[1000];
int main()
{
    long long n,m;
    cin>>n>>m;
    long long arr[m+1][n+1];
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            cin>>arr[i][j];
        }
    }
    int mx=INT_MIN,p=0;
    for(int i=0;i<m;i++){
            mx=-1;
        for(int j=0;j<n;j++){
            if(arr[i][j]>mx){
                mx=arr[i][j];
                p=j+1;
            }
        }
        cnt[p]++;

    }
    for(int i=0;i<m;i++){
        if(cnt[i]>mx)
            mx=cnt[i];
            p=i;
    }
    cout<<p+1<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int cnt[1000];
int main()
{
    long long n,m;
    cin>>n>>m;
    long long arr[m+1][n+1];
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            cin>>arr[i][j];
        }
    }
    int mx=INT_MIN,p=0;
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            if(arr[i][j]>mx){
                mx=arr[i][j];
                p=j+1;
            }
        }
        cnt[p]++;
        mx=0;
    }
    for(int i=1;i<=n;i++){
        if(cnt[i]>mx){
            mx=cnt[i];
            p=i;
        }
    }
    cout<<p<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int cnt[1000];
int main()
{
    long long n,m;
    cin>>n>>m;
    long long arr[m+1][n+1];
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            cin>>arr[i][j];
        }
    }
    for(int i=0;i<m;i++){
            int mx=-1,p;
        for(int j=0;j<n;j++){
            if(arr[i][j]>mx){
                mx=arr[i][j];
                p=j;
            }
        }
        cnt[p]++;

    }
    int mx=-1,p;
    for(int i=0;i<n;i++){
            if(cnt[i]>mx){
                mx=cnt[i];
                p=i;
            }

    }
    cout<<p+1<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int cnt[1000];
int main()
{
    long long n,m;
    cin>>n>>m;
    long long arr[m+1][n+1];
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            cin>>arr[i][j];
        }
    }
    int mx=INT_MIN,p=0;
    for(int i=0;i<m;i++){
            mx=-1;
        for(int j=0;j<n;j++){
            if(arr[i][j]>mx){
                mx=arr[i][j];
                p=j+1;
            }
        }
        cnt[p]++;

    }
    mx=-1;
    for(int i=1;i<=m;i++){
        if(cnt[i]>mx)
            mx=cnt[i];
            p=i;
    }
    cout<<p<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int cnt[1000];
int main()
{
    long long n,m;
    cin>>n>>m;
    long long arr[m+1][n+1];
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            cin>>arr[i][j];
        }
    }
    int mx=INT_MIN,p=0;
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            if(arr[i][j]>mx){
                mx=arr[i][j];
                p=j+1;
            }
        }
        cnt[p]++;
        mx=-1;
    }
    for(int i=1;i<=n;i++){
        if(cnt[i]>mx){
            mx=cnt[i];
            p=i;
        }
    }
    cout<<p<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int cnt[1000];
int main()
{
    long long n,m;
    cin>>n>>m;
    long long arr[m+1][n+1];
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            cin>>arr[i][j];
        }
    }
    int mx=INT_MIN,p=0;
    for(int i=0;i<m;i++){
            mx=-1;
        for(int j=0;j<n;j++){
            if(arr[i][j]>mx){
                mx=arr[i][j];
                p=j;
            }
        }
        cnt[p]++;

    }
    mx=-1;
    for(int i=0;i<n;i++){
        if(cnt[i]>mx)
            mx=cnt[i];
            p=i;
    }
    cout<<p<<endl;
    return 0;
}


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

int n ,m ,y;
long long a,b;
int arr[102];

int main()
{
    cin>>n>>m;
    for(int i=0;i<m;i++){
        b=0;
        for(int j=1;j<=n;j++){
            cin>>a;
            if(a==0) continue;
            if(a<=b) continue;
            else if(b<a){
                    b=a;
                    y=j;
            }

        }
        arr[y]++;

    }
    b=0;
    y=0;
   for(int i=0;i<102;i++){
        if(arr[i]==0) continue;
        if(arr[i]>b) {
            b=arr[i];
            y=i;
        }

   }

   cout<<y;
    return 0;
}


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

int n ,m ,y;
long long a,b;
int arr[102];

int main()
{
    cin>>n>>m;
    for(int i=0;i<m;i++){
        b=0;
        for(int j=1;j<=n;j++){
            cin>>a;
            if(a<=b) continue;
            else if(b<a){
                    b=a;
                    y=j;
            }

        }
        arr[y]++;

    }

    sort(arr,arr+102);

    cout<<arr[101];
    return 0;
}


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

int n ,m ,y;
long long a,b;
int arr[102];

int main()
{
    cin>>n>>m;
    for(int i=0;i<m;i++){
        b=0;
        y=0;
        for(int j=1;j<=n;j++){
            cin>>a;

            if(a<=b) continue;
            else if(b<a){
                    b=a;
                    y=j;
            }

        }
        if(y==0) arr[1]++;
        else arr[y]++;

    }
    b=0;
    y=0;
   for(int i=0;i<102;i++){
        if(arr[i]>b) {
            b=arr[i];
            y=i;
        }

   }
   if(y==0) cout<<1;
   else
   cout<<y;
    return 0;
}


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

int n ,m ,y;
long long a,b;
int arr[102];

int main()
{
    cin>>n>>m;
    for(int i=0;i<m;i++){
        b=0;
        for(int j=1;j<=n;j++){
            cin>>a;
            if(a<=b) continue;
            else if(b<a){
                    b=a;
                    y=j;
            }

        }
        arr[y]++;

    }
    b=0;
   for(int i=0;i<102;i++){
        if(arr[i]>b) {
            b=arr[i];
            y=i;
        }

   }

   cout<<y;
    return 0;
}


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

int n ,m ,y;
long long a,b;
int arr[101];

int main()
{
    cin>>n>>m;
    for(int i=0;i<n;i++){
        b=0;
        for(int j=0;j<m;j++){
            cin>>a;
            if(a==b) continue;
            else if(b<a){
                    b=max(b,a);
                    y=j;
            }

        }
        arr[y]++;

    }

    sort(arr,arr+101);

    cout<<arr[100];
    return 0;
}


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

int n ,m ,y;
long long a,b;
int arr[102];

int main()
{
    cin>>n>>m;
    for(int i=0;i<m;i++){
        b=0;
        for(int j=1;j<=n;j++){
            cin>>a;
            if(a<=b) continue;
            else if(b<a){
                    b=a;
                    y=j;
            }

        }
        arr[y]++;

    }
    b=0;
    y=0;
   for(int i=0;i<102;i++){
        if(arr[i]>b) {
            b=arr[i];
            y=i;
        }

   }

   cout<<y;
    return 0;
}


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

int n ,m ,y;
long long a,b;
int arr[102];

int main()
{
    cin>>n>>m;
    for(int i=0;i<m;i++){
        b=0;
        for(int j=1;j<=n;j++){
            cin>>a;
            if(a<=b) continue;
            else if(b<a){
                    b=a;
                    y=j;
            }

        }
        arr[y]++;

    }
    b=0;
    y=0;
   for(int i=0;i<102;i++){
        if(arr[i]>b) {
            b=arr[i];
            y=i;
        }

   }
   if(y==0) cout<<1;
   else
   cout<<y;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n, a[55], b[55];

map <int , int> f , p;

int main()
{
	cin >> n;
	for (int i = 1; i <= n * n; i++)
	{
		cin >> a[i] >> b[i];
		if (f[a[i]] == 0 && p[b[i]] == 0)
		{
			cout << i << ' ';
			f[a[i]]++;
			p[b[i]]++;
		}
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n, m, a[105][105], c[105], mx, mmx, id;

map <int , int> f;

int main()
{
	cin >> n >> m;
	for (int i = 1; i <= m; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			cin >> a[i][j];
			if (a[i][j] > mx)
			{
				c[i] = j;
				mx = a[i][j];
			}
		}
		mx = 0;
	}
	for (int i = 1; i <= m; i++)
	{
		f[c[i]]++;
	}
	for (int i = 0; i <= 100; i++)
	{
		if (f[i] > mmx)
		{
			id = i;
			mmx = f[i];
		}
	}
	cout << id;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n, m, a[105][105], c[105], mx, mmx, id;

map <int , int> f;

int main()
{
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			cin >> a[i][j];
			if (a[i][j] > mx)
			{
				c[i] = j;
				mx = a[i][j];
			}
		}
		mx = 0;
	}
	for (int i = 1; i <= n; i++)
	{
		f[c[i]]++;
	}
	for (int i = 0; i <= n; i++)
	{
		if (f[i] > mmx)
		{
			id = i;
			mmx = f[i];
		}
	}
	cout << id;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n, m, a[105][105], q, v[105], id, mx = -1;

int main()
{
	cin >> n >> m;
	for (int i = 1; i <= m; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			cin >> a[i][j];
			if (a[i][j] > a[i][q])
			{
				q = j;
			}
		}
		v[q]++;
	}
	for (int i = 0; i <= m; i++)
	{
		if (v[i] > mx)
		{
			mx = v[i];
			id = i;
		}
	}
	if (id == 0)
	{
		id++;
	}
	cout << id;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
int main()
{
    int n,m;
    cin>>n>>m;
    int ar[m+1][n+1],i,j,earmx[m+1];
    for(i=1;i<=m;i++)
        earmx[i]=0;
    for(i=1;i<=m;i++)
    {
        int m1=0,p,f=0;
        for(j=1;j<=n;j++)
        {
            cin>>ar[i][j];
            if(i==0)
            {
                if(j==0)
                    m1=ar[i][j];
                if(ar[i][j]>m1)
                {
                    m1=ar[i][j];
                    earmx[j]++;
                    p=j;
                    f=1;
                }
            }
            else
            {
                if(ar[i][j]>m1)
                {
                    m1=ar[i][j];
                    p=j;
                    f=1;
                }
            }
        }
        if(f)
            earmx[p]++;
        //cout<<"ER="<<earmx[p]<<" "<<p<<endl;
    }
    int ind=0,maxv=0;
    for(i=1;i<=n;i++)
    {
        if(earmx[i]>maxv)
        {
            maxv=earmx[i];
            ind=i;
            //cout<<"M="<<maxv<<" ind="<<ind<<endl;
        }
    }
    cout<<ind<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
int main()
{
    int n,m;
    cin>>n>>m;
    int ar[m+1][n+1],i,j,earmx[m+1];
    for(i=1;i<=m;i++)
        earmx[i]=0;
    for(i=1;i<=m;i++)
    {
        int m1=0,p;
        for(j=1;j<=n;j++)
        {
            cin>>ar[i][j];
            if(i==0)
            {
                if(j==0)
                    m1=ar[i][j];
                if(ar[i][j]>m1)
                {
                    m1=ar[i][j];
                    earmx[j]++;
                }
            }
            else
            {
                if(ar[i][j]>m1)
                {
                    m1=ar[i][j];
                    p=j;
                }
            }
        }
        earmx[p]++;
        //cout<<"ER="<<earmx[p]<<" "<<p<<endl;
    }
    int ind=0,maxv=0;
    for(i=1;i<=m;i++)
    {
        if(earmx[i]>maxv)
        {
            maxv=earmx[i];
            ind=i;
            //cout<<"M="<<maxv<<" ind="<<ind<<endl;
        }
    }
    cout<<ind<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
int main()
{
    int n,m;
    cin>>n>>m;
    int ar[m+1][n+1],i,j,earmx[m+1];
    for(i=1;i<=n;i++)
        earmx[i]=0;
    for(i=1;i<=m;i++)
    {
        int m1=0,p,f=0;
        for(j=1;j<=n;j++)
        {
            cin>>ar[i][j];
            if(i==0)
            {
                if(j==0)
                    m1=ar[i][j];
                if(ar[i][j]>m1)
                {
                    m1=ar[i][j];
                    earmx[j]++;
                    p=j;
                    f=1;
                }
            }
            else
            {
                if(ar[i][j]>m1)
                {
                    m1=ar[i][j];
                    p=j;
                    f=1;
                }
            }
        }
        if(f)
            earmx[p]++;
        //cout<<"ER="<<earmx[p]<<" "<<p<<endl;
    }
    int ind=0,maxv=0;
    for(i=1;i<=n;i++)
    {
        if(earmx[i]>maxv)
        {
            maxv=earmx[i];
            ind=i;
            //cout<<"M="<<maxv<<" ind="<<ind<<endl;
        }
    }
    cout<<ind<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
int main()
{
    int n,m;
    cin>>n>>m;
    int ar[m+1][n+1],i,j,earmx[m+1];
    for(i=1;i<=n;i++)
        earmx[i]=0;
    for(i=1;i<=m;i++)
    {
        int m1=0,p;
        for(j=1;j<=n;j++)
        {
            cin>>ar[i][j];
            if(i==0)
            {
                if(j==0)
                    m1=ar[i][j];
                if(ar[i][j]>m1)
                {
                    m1=ar[i][j];
                    earmx[j]++;
                    p=j;
                }
            }
            else
            {
                if(ar[i][j]>m1)
                {
                    m1=ar[i][j];
                    p=j;
                }
            }
        }
        earmx[p]++;
        //cout<<"ER="<<earmx[p]<<" "<<p<<endl;
    }
    int ind=0,maxv=0;
    for(i=1;i<=n;i++)
    {
        if(earmx[i]>maxv)
        {
            maxv=earmx[i];
            ind=i;
            //cout<<"M="<<maxv<<" ind="<<ind<<endl;
        }
    }
    cout<<ind<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
int f;
int main()
{
    int n,m;
    cin>>n>>m;
    int ar[m+1][n+1],i,j,earmx[m+1];
    for(i=1;i<=n;i++)
        earmx[i]=0;
    for(i=1;i<=m;i++)
    {
        int m1=0,p;
        for(j=1;j<=n;j++)
        {
            cin>>ar[i][j];
            if(i==0)
            {
                if(j==0)
                    m1=ar[i][j];
                if(ar[i][j]>m1)
                {
                    m1=ar[i][j];
                    earmx[j]++;
                    p=j;
                    f=1;
                }
            }
            else
            {
                if(ar[i][j]>m1)
                {
                    m1=ar[i][j];
                    p=j;
                    f=1;
                }
            }
        }
        if(f)
            earmx[p]++;
        //cout<<"ER="<<earmx[p]<<" "<<p<<endl;
    }
    if(f)
    {
        int ind=0,maxv=0;
        for(i=1;i<=n;i++)
        {
            if(earmx[i]>maxv)
            {
                maxv=earmx[i];
                ind=i;
                //cout<<"M="<<maxv<<" ind="<<ind<<endl;
            }
        }
        cout<<ind<<endl;
    }
    else
        cout<<"1"<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
int f;
int main()
{
    int n,m;
    cin>>n>>m;
    int ar[m+1][n+1],i,j,earmx[m+1];
    for(i=1;i<=n;i++)
        earmx[i]=0;
    for(i=1;i<=m;i++)
    {
        int m1=0,p,c=0;
        for(j=1;j<=n;j++)
        {
            cin>>ar[i][j];
            if(i==0)
            {
                if(j==0)
                    m1=ar[i][j];
                if(!ar[i][j]);
                    c++;
                if(ar[i][j]>m1)
                {
                    m1=ar[i][j];
                    earmx[j]++;
                    p=j;
                    f=1;
                }
            }
            else
            {
                if(!ar[i][j])
                    c++;
                if(ar[i][j]>m1)
                {
                    m1=ar[i][j];
                    p=j;
                    f=1;
                }
            }
        }
        //cout<<"C="<<c<<endl;
        if(f && c!=n)
            earmx[p]++;
        else if(c==n)
        {
            //cout<<"Poo"<<endl;
            earmx[1]++;
            f=1;
        }
        //cout<<"ER="<<earmx[p]<<" "<<p<<endl;
    }
    if(f)
    {
        int ind=0,maxv=0;
        for(i=1;i<=n;i++)
        {
            //cout<<earmx[i]<<" ";
            if(earmx[i]>maxv)
            {
                maxv=earmx[i];
                ind=i;
                //cout<<"M="<<maxv<<" ind="<<ind<<endl;
            }
        }
        cout<<endl;
        cout<<ind<<endl;
    }
    else
        cout<<"1"<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
int main()
{
    int n,m;
    cin>>n>>m;
    int ar[m+1][n+1],i,j,earmx[m+1];
    for(i=1;i<=m;i++)
        earmx[i]=0;
    for(i=1;i<=m;i++)
    {
        int m1=0,p;
        for(j=1;j<=n;j++)
        {
            cin>>ar[i][j];
            if(i==0)
            {
                if(j==0)
                    m1=ar[i][j];
                if(ar[i][j]>m1)
                {
                    m1=ar[i][j];
                    earmx[j]++;
                }
            }
            else
            {
                if(ar[i][j]>m1)
                {
                    m1=ar[i][j];
                    p=j;
                }
            }
        }
        earmx[p]++;
        //cout<<"ER="<<earmx[p]<<" "<<p<<endl;
    }
    int ind=0,maxv=0;
    for(i=1;i<=n;i++)
    {
        if(earmx[i]>maxv)
        {
            maxv=earmx[i];
            ind=i;
            //cout<<"M="<<maxv<<" ind="<<ind<<endl;
        }
    }
    cout<<ind<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
int main()
{
    int n,m;
    cin>>n>>m;
    int ar[m+1][n+1],i,j,earmx[m+1];
    for(i=1;i<=m;i++)
        earmx[i]=0;
    for(i=1;i<=m;i++)
    {
        int m1=0,p;
        for(j=1;j<=n;j++)
        {
            cin>>ar[i][j];
            if(i==0)
            {
                if(j==0)
                    m1=ar[i][j];
                if(ar[i][j]>m1)
                {
                    m1=ar[i][j];
                    earmx[j]++;
                    p=j;
                }
            }
            else
            {
                if(ar[i][j]>m1)
                {
                    m1=ar[i][j];
                    p=j;
                }
            }
        }
        earmx[p]++;
        //cout<<"ER="<<earmx[p]<<" "<<p<<endl;
    }
    int ind=0,maxv=0;
    for(i=1;i<=n;i++)
    {
        if(earmx[i]>maxv)
        {
            maxv=earmx[i];
            ind=i;
            //cout<<"M="<<maxv<<" ind="<<ind<<endl;
        }
    }
    cout<<ind<<endl;
    return 0;
}


#include <set>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <cstring>
#include <map>
#include <algorithm>
using namespace std;
int main()
{
    int n , m ,  ma;
    cin>>n>>m ;
    int   x, w[m] ,w1[100]={0};
  for (int i=0 ; i<m ; i++)
    {
         ma=0;
        for (int j=0 ; j<n ; j++)
        {
            cin>>x;
            if (ma<x)
            {
                w[i]=j;
                ma=x;
            }
        }
    }
    for (int i=0 ; i<m ; i++)
        w1[w[i]]++;
         ma=0;

        for (int i=0 ; i<n ; i++)
        {
            if (ma<w1[i])
            {
                x=i+1;
                ma=w1[i];
            }
        }
        cout<<x<<endl;

    return 0;
}


#include <set>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <cstring>
#include <map>
#include <algorithm>
using namespace std;
int main()
{
    int n , m ,a;
    cin>>n>>m ;
    int x[m][n] , w[m] ,w1[100]={0};
  for (int i=0 ; i<m ; i++)
    {
        int ma=0;
        for (int j=0 ; j<n ; j++)
        {
            cin>>x[i][j];
            if (ma<x[i][j])
            {
                w[i]=j+1;
                ma=x[i][j];

            }
        }
    }
    for (int i=0 ; i<n ; i++)
        w1[w[i]]++;
        int maxx=0;
        for (int i=0 ; i<n ; i++)
        {
            if (maxx<w1[i])
            {
                a=i;
            }
        }
        cout<<a<<endl;

    return 0;
}


#include <set>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <cstring>
#include <map>
#include <algorithm>
using namespace std;
int main()
{
    int n , m ,a,ma;
    cin>>n>>m ;
    int x[m][n] , w[m] ,w1[100]={0};
  for (int i=0 ; i<m ; i++)
    {
         ma=0;
        for (int j=0 ; j<n ; j++)
        {
            cin>>x[i][j];
            if (ma<x[i][j])
            {
                w[i]=j;
                ma=x[i][j];
            }
        }
    }
    for (int i=0 ; i<n ; i++)
        w1[w[i]]++;
         ma=0;

        for (int i=0 ; i<n ; i++)
        {
            if (ma<w1[i])
            {
                a=i+1;
                ma=w1[i];
            }
        }
        cout<<a<<endl;

    return 0;
}


#include <set>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <cstring>
#include <map>
#include <algorithm>
using namespace std;
int main()
{
    int n , m ,a,ma;
    cin>>n>>m ;
    int x, w[m] ,w1[100]={0};
  for (int i=0 ; i<m ; i++)
    {
         ma=0;
        for (int j=0 ; j<n ; j++)
        {
            cin>>x;
            if (ma<x)
            {
                w[i]=j;
                ma=;
            }
        }
    }
    for (int i=0 ; i<m ; i++)
        w1[w[i]]++;
         ma=0;

        for (int i=0 ; i<n ; i++)
        {
            if (ma<w1[i])
            {
                a=i+1;
                ma=w1[i];
            }
        }
        cout<<a<<endl;

    return 0;
}


#include <set>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <cstring>
#include <map>
#include <algorithm>
using namespace std;
int main()
{
    int n , m ,a,ma;
    cin>>n>>m ;
    int x[m][n] , w[m] ,w1[100]={0};
  for (int i=0 ; i<m ; i++)
    {
         ma=0;
        for (int j=0 ; j<n ; j++)
        {
            cin>>x[i][j];
            if (ma<x[i][j])
            {
                w[i]=j;
                ma=x[i][j];
            }
        }
    }
    for (int i=0 ; i<n ; i++)
        w1[w[i]]++;
         ma=0;
         for (int i=0 ; i<m ; i++)
         {
             cout<<w[i]<<"      "<<w1[i]<<endl;
         }
        for (int i=0 ; i<n ; i++)
        {
            if (ma<w1[i])
            {
                a=i+1;
                ma=w1[i];
            }
        }
        cout<<a<<endl;

    return 0;
}


#include <set>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <cstring>
#include <map>
#include <algorithm>
using namespace std;
int main()
{
    int n , m ,a,ma;
    cin>>n>>m ;
    int x, w[m] ,w1[100]={0};
  for (int i=0 ; i<m ; i++)
    {
         ma=0;
        for (int j=0 ; j<n ; j++)
        {
            cin>>x;
            if (ma<x)
            {
                w[i]=j;
                ma=x;
            }
        }
    }
    for (int i=0 ; i<m ; i++)
        w1[w[i]]++;
         ma=0;

        for (int i=0 ; i<n ; i++)
        {
            if (ma<w1[i])
            {
                a=i+1;
                ma=w1[i];
            }
        }
        cout<<a<<endl;

    return 0;
}


#include <set>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <cstring>
#include <map>
#include <algorithm>
using namespace std;
int main()
{
    int n , m , a , ma;
    cin>>n>>m ;
    int x, w[m] ,w1[100]={0};
  for (int i=0 ; i<m ; i++)
    {
         ma=0;
        for (int j=0 ; j<n ; j++)
        {
            cin>>x;
            if (ma<x)
            {
                w[i]=j;
                ma=x;
            }
        }
    }
    for (int i=0 ; i<m ; i++)
        w1[w[i]]++;
         ma=0;

        for (int i=0 ; i<n ; i++)
        {
            if (ma<w1[i])
            {
                a=i+1;
                ma=w1[i];
            }
        }
        cout<<a<<endl;

    return 0;
}


#include <set>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <cstring>
#include <map>
#include <algorithm>
using namespace std;
int main()
{
    int n , m ,x,p[1001],w[1001]={0}, maxx=0;
   cin>>n>>m;
   for (int i=0 ; i<m ; i++)
   {
       maxx=0;
       for (int j=0 ; j<n ; j++)
       {
           cin>>x;
           if (maxx<x)
           {
               maxx=x;
               p[i]=j;
           }
       }
   }
   for (int i=0 ; i<m ; i++)
   w[p[i]]++;
   maxx=0;
   for (int i=0 ; i<n; i++)
   {
       if (w[i]>maxx)
       {
           maxx=w[i];
           x=i+1;
       }
   }
   cout<<x<<endl;
    return 0;
}


#include <set>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <cstring>
#include <map>
#include <algorithm>
using namespace std;
int main()
{
    int n , m ,a,ma;
    cin>>n>>m ;
    int x[m][n] , w[m] ,w1[100]={0};
  for (int i=0 ; i<m ; i++)
    {
         ma=0;
        for (int j=0 ; j<n ; j++)
        {
            cin>>x[i][j];
            if (ma<x[i][j])
            {
                w[i]=j;
                ma=x[i][j];
            }
        }
    }
    for (int i=0 ; i<m ; i++)
        w1[w[i]]++;
         ma=0;

        for (int i=0 ; i<n ; i++)
        {
            if (ma<w1[i])
            {
                a=i+1;
                ma=w1[i];
            }
        }
        cout<<a<<endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = (a); i <= (b); i++)
#define red(i, a, b) for(int i = (a); i >= (b); i--)
#define ll long long

const int N = 200, M = 200;
int n, m;
int a[N][M], vote[M];

int main() {
	scanf("%d%d", &n, &m);
	memset(vote, 0, sizeof(vote));
	rep(i, 1, m) {
		int maxn = -1, maxi = 0;
		rep(j, 1, n) {
			scanf("%d", &a[i][j]);
			if (a[i][j] > maxn) { maxn = a[i][j]; maxi = j; }
		}
		vote[maxi]++;
	}
	int ansn = 0, ansi = 0;
	rep(i, 1, n)
		if (vote[i] > ansn) {
			ansn = vote[i];
			ansi = i;
		}
	printf("%d\n", ansi);
	return 0;
}


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

const int N = 1111;
int n, m, a[N][N], cnt[N];

int main(){
	scanf("%d%d", &m, &n);
	memset(cnt, 0, sizeof(cnt));
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			scanf("%d", &a[i][j]);

	for (int i = 1; i <= n; i++){
		int _max = -1, maxnum = 0;
		for (int j = 1; j <= m; j++)
			if (a[i][j] > _max){
				_max = a[i][j]; maxnum = j;
			}
		cnt[maxnum]++;
	}

	int _max = 0, maxnum = 0;
	for (int i = 1; i <= m; i++)
		if (cnt[i] > _max){
			_max = cnt[i]; maxnum = i;
		}
	printf("%d\n", maxnum);

	return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;

const int N = 1111;
int n, m, a[N][N], cnt[N];

int main(){
	scanf("%d%d", &m, &n);
	memset(cnt, 0, sizeof(cnt));
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			scanf("%d", &a[i][j]);

	for (int i = 1; i <= n; i++){
		int _max = -1, maxnum = 0;
		for (int j = 1; j <= m; j++)
			if (a[i][j] > _max){
				_max = a[i][j]; maxnum = j;
			}
		cnt[maxnum]++;
	}

	int _max = 0, maxnum = 0;
	for (int i = 1; i <= m; i++)
		if (cnt[i] > _max){
			_max = cnt[i]; maxnum = i;
		}
	printf("%d\n", maxnum);

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = (a); i <= (b); i++)
#define red(i, a, b) for(int i = (a); i >= (b); i--)
#define ll long long

const int N = 200, M = 200;
int n, m;
int a[N][M], vote[M];

int main() {
	scanf("%d%d", &n, &m);
	memset(vote, 0, sizeof(vote));
	rep(i, 1, n) {
		int maxn = 0, maxi = 0;
		rep(j, 1, m) {
			scanf("%d", &a[i][j]);
			if (a[i][j] > maxn) { maxn = a[i][j]; maxi = j; }
		}
		vote[maxi]++;
	}
	int ansn = 0, ansi = 0;
	rep(i, 1, m)
		if (vote[i] > ansn) {
			ansn = vote[i];
			ansi = i;
		}
	printf("%d\n", ansi);
	return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;

const int N = 1111;
int n, m, a[N][N], cnt[N];

int main(){
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			scanf("%d", &a[i][j]);

	for (int i = 1; i <= n; i++){
		int max = -0x3f3f3f3f, maxnum = -1;
		for (int j = 1; j <= m; j++)
			if (a[i][j] > max){
				max = a[i][j]; maxnum = j;
			}
		cnt[maxnum]++;
	}

	int max = -0x3f3f3f3f, maxnum = -1;
	for (int i = 1; i <= m; i++)
		if (cnt[i] > max){
			max = cnt[i]; maxnum = i;
		}
	printf("%d\n", maxnum);

	return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;

const int N = 1111;
int n, m, a[N][N], cnt[N];

int main(){
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			scanf("%d", &a[i][j]);

	for (int i = 1; i <= n; i++){
		int _max = 0, maxnum = 0;
		for (int j = 1; j <= m; j++)
			if (a[i][j] > _max){
				_max = a[i][j]; maxnum = j;
			}
		cnt[maxnum]++;
	}

	int _max = 0, maxnum = 0;
	for (int i = 1; i <= m; i++)
		if (cnt[i] > _max){
			_max = cnt[i]; maxnum = i;
		}
	printf("%d\n", maxnum);

	return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;

const int N = 1111;
int n, m, a[N][N], cnt[N];

int main(){
	scanf("%d%d", &m, &n);
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			scanf("%d", &a[i][j]);

	for (int i = 1; i <= n; i++){
		int _max = 0, maxnum = 0;
		for (int j = 1; j <= m; j++)
			if (a[i][j] > _max){
				_max = a[i][j]; maxnum = j;
			}
		cnt[maxnum]++;
	}

	int _max = 0, maxnum = 0;
	for (int i = 1; i <= m; i++)
		if (cnt[i] > _max){
			_max = cnt[i]; maxnum = i;
		}
	printf("%d\n", maxnum);

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = (a); i <= (b); i++)
#define red(i, a, b) for(int i = (a); i >= (b); i--)
#define ll long long

const int N = 200, M = 200;
int n, m;
int a[N][M], vote[M];

int main() {
	scanf("%d%d", &n, &m);
	memset(vote, 0, sizeof(vote));
	rep(i, 1, n) {
		int maxn = -1, maxi = 0;
		rep(j, 1, m) {
			scanf("%d", &a[i][j]);
			if (a[i][j] > maxn) { maxn = a[i][j]; maxi = j; }
		}
		vote[maxi]++;
	}
	int ansn = 0, ansi = 0;
	rep(i, 1, m)
		if (vote[i] > ansn) {
			ansn = vote[i];
			ansi = i;
		}
	printf("%d\n", ansi);
	return 0;
}


#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<vector>
#include<stack>
#define y0 abc111qqz
#define y1 hust111qqz
#define yn hez111qqz
#define j1 cute111qqz
#define tm crazy111qqz
#define lr dying111qqz
using namespace std;
#define REP(i, n) for (int i=0;i<int(n);++i)
typedef long long LL;
typedef unsigned long long ULL;
const int inf = 0x7fffffff;
const int N=1E2+5;
int a[N][N];
int n,m;
int mx;
int cnt[N];
int main()
{
  cin>>n>>m;
  for ( int i = 1 ; i<= m ; i ++)
  {
    for ( int j = 1 ; j <= n ; j++ )
    {
      scanf("%d",&a[i][j]);
    }
  }
  memset(cnt,0,sizeof(cnt));
  for ( int i = 1 ; i <= m ; i++ )
  {
    mx = -1;
    int p = -1;
    for ( int j = 1 ; j <= n ; j++ )
    {
      if (a[i][j]>mx)
      {
        mx = a[i][j];
        p = j;
      }
    }
    cnt[p]++;
  }
  mx = -1;
  int ans;
  for ( int i = 1 ; i<= n ; i++)
  {
    if (cnt[i]>mx)
    {
      mx = cnt[i];
      ans = i;
    }
  }
  cout<<ans<<endl;
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
int m,n;
struct people{
	int cnt,d;
} p[101];
bool cmp(people a,people b){
	return a.cnt>b.cnt;
}
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++) p[i].d=i;
	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++){
			int x;
			cin>>x;
			p[j].cnt=max(p[j].cnt,x);
	    }
	}
	sort(p+1,p+n+1,cmp);
	cout<<p[1].d;
}


#include<bits/stdc++.h>
using namespace std;
const int MAXN=111;
int num[MAXN];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int maxn1=-1,ans=0;
		for(int j=1;j<=n;j++){
			int a;
			cin>>a;
			if(a>maxn1)
				maxn1=a,ans=j;
		}
		num[ans]++;
	}
	int maxn1=-1,ans1=0;
	for(int i=1;i<=n;i++){
		if(num[i]>maxn1)
			maxn1=num[i],ans1=i;
	}
	cout<<ans1;
	return 0;
}


#include <iostream>
using namespace std;
int x[100],n,m,j,i,d,e,a;
int main()
{
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        int b=-1,c;
        for(j=0;j<n;j++)
        {
            cin>>a;
            if(a>b)
            {
                b=a;
                c=j;
            }
        }
        x[c]++;
    }
    for(i=0;i<101;i++)
    if(x[i]>d)
    {
        d=x[i];
        e=i+1;
    }
    cout<<e;
    return 0;
}


#define _CRT_SBCURE_NO_DEPRECATE
#include <iostream>
#include <memory.h>
typedef unsigned long long ll;

using namespace std;

const int MAXN = 10000;
const int INF = 0x3f3f3f3f;

int p[MAXN];
int main()
{
    memset(p, 0, sizeof(p));
    int n, m;
    cin >> n >> m;

    int ans = -INF;
    int check = 1;
    for(int i = 1; i <= m; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            int temp;
            cin >> temp;
            p[j] += temp;
        }
    }

    for(int i = 1; i <= n; i++)
    {
        //cout << p[i] << endl;
        if(p[i] > ans)
        {
            ans = p[i];
            check = i;
        }
    }

    cout << check;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int m,n,a[101][101];
int b[101],ans=-1,s;
int main()
{
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	for(int j=1;j<=n;j++)
	{
		cin>>a[i][j];
		b[j]+=a[i][j];
	}
	for(int i=1;i<=n;i++)
	{
		if(b[i]>ans){
			ans=b[i];
			s=i;
		}
	}
	cout<<s;
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<string>
#include<cstdlib>
using namespace std;
int n,m,a[101],x,now,ma,maxn,maa=1;
int main(){
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        now=0;maxn=0;
        for(int j=1;j<=n;j++){
            cin>>x;
            if(x>maxn){
                maxn=x;
                now=j;
            }
        }
        a[now]++;
    }
    for(int i=1;i<=n;i++)
        if(a[i]>ma){
        	ma=a[i];
        	maa=i;
        }
    cout<<maa;
    return 0;
}


#include<cstdio>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<fstream>
using namespace std;
struct pep{
	int num;
	int w;
};
bool cmp(pep a,pep b)
{
	if(a.w==b.w)
	{
		return a.num<b.num;
	}
	return a.w>b.w;
}
int main()
{
	int n,m;
	int k;
	cin>>n>>m;
	pep a[n+1];
	for(int i=1;i<=n;i++)
	{
		a[i].num=i;
		a[i].w=0;
	}
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=n;j++)
		{
			cin>>k;
			a[j].w+=k;
		}
	}
	sort(a+1,a+n+1,cmp);
	cout<<a[1].num<<endl;
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<cstring>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<sstream>
#include<cstdlib>
#define F(i,s,t) for(int i=(s);i<=(t);i++)
#define D(i,s,t) for(int i=(s);i>=(t);i--)
#define dBug(i) printf("Value=%d\n",i)
#define ed putchar('\n')
#define FO freopen("D:\\in.txt","r",stdin)
#define IOS cin.tie(0) ,cout.tie(0), cout.sync_with_stdio(0)
typedef long long ll;
const int INF = 1 << 30;
const double EPS = 1e-6;
#define MX 110
//#define Mod 998244353
using namespace std;

int N, M, a, maxn, peo, w[MX], t[MX];

int main()
{
	IOS;
	FO;
	cin >> N >> M;
	F(i, 1, M){
		maxn = -1, peo = -1;
		F(j, 1, N){
			cin >> a;
			if (a > maxn) maxn = a, peo = j;//找出每个城市获票最多的人
		}//F(j, 1, N){
		w[peo]++;//这个人获得一票
	}
	F(i, 1, N) t[i] = w[i];//w[i]复制到t[i]中

	int cnt;
	sort(t + 1, t + N + 1);
	cnt = unique(t + 1, t + N + 1) - t - 1;
	//dBug(t[cnt]); ed;
	F(i, 1, N)
	if (t[cnt] == w[i]){
		cout << i << endl;
		break;
	}
	return 0;
}


#include <iostream>
using namespace std;
const int N = 110;
int a[N][N], s[N];
int n, m;

int main()
{
    int max = 0, l = 0;
    cin >> n >> m;
    for (int i = 0; i < n; i ++)
        for (int j = 0; j < m; j ++)
        {
            cin >> a[i][j];
            s[j] += a[i][j];
        }

    for (int i = 0; i < n; i ++)
    {
        if (s[i] > max)
        {
            max = s[i];
            l = i;
        }
    }
    cout << l << endl;
    return 0;
}


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

const int N = 110;

int x,k,p[N];
int n,m,Max;

int main()
{
    scanf("%d %d",&n,&m);

    for(int i=1; i<=m; i++) //m个城市 n个人  统计各城市胜出的人的编号k
    {
        Max = INT_MIN;//Max 每一行 每个城市的得票最多的人的票数  每一行都要清空
        k = 0;

        for(int j=1; j<=n; j++)
        {
            scanf("%d",&x);
            if(x > Max)
            {
                Max = x;
                k = j;
            }
        }

        p[k]++; //p数组 存储第i个人 在多个城市中胜出的次数
    }

    k = 0;
    Max = INT_MIN;

    for(int i=1; i<=n; i++) //统计出胜出次数最多的人 城市编号从小到大
        if(p[i] > Max)
        {
            Max = p[i];
            k = i;
        }

    printf("%d\n",k);

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int m,n;
int x,k;
int ans,maxn;
int a[110];
int mn[110];
int cmp(int a,int b){
	return a>b;
}
int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
	  x=0;
	  k=0;
	  for(int j=1;j<=n;j++){
	 	cin>>mn[j];
	 	if(mn[j]>x){
	 		x=mn[j];
	 		k=j;
		 }
	  }
	  a[k]++;
	}
	a[0]=0;
	for(int i=1;i<=n;i++){
		if(a[i]>maxn){
			maxn=a[i];
			ans=i;
		}
	}
	cout<<ans;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n,m,a[111],b[111];
int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int mx=0;
		for(int j=1;j<=n;j++){
			cin>>a[j];
			mx=max(mx,a[j]);
		}
		//sort(a+1,a+1+m);
		//reverse(a+1,a+1+m);
		for(int j=1;j<=n;j++){
			if(a[j]==mx){
				b[j]++;
				break;
			}
		}
	}
	int mxx=0;
	for(int i=1;i<=n;i++){
		mxx=max(mxx,b[i]);
	}
	for(int i=1;i<=n;i++){
		if(mxx==b[i]){
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}


#include<cstdio>
using namespace std;
int n,m,a,mx,mt,ans=1,s,t[101];
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;++i){
        mx=0;
        mt=1;
        for(int j=1;j<=n;++j){
            scanf("%d",&a);
            if(a>mx){
                mx=a;
                mt=j;
            }
        }
        ++t[mt];
        if(t[mt]>=s){
            if(t[mt]>s||mt<ans)ans=mt;
            s=t[mt];
        }
    }
    printf("%d",ans);
}


#include <iostream>
using namespace std;
int p[121621],a[121621];
int main(int argc, char** argv) {
	int n,m;
	cin >> n >> m;
	for(int i=0;i<m;i++)
	{
		int ma=0,w=0;
		for(int j=0;j<n;j++)
		{
			cin >> a[j];
			if(a[j]>ma)
			{
				ma=a[j];
				w=j;
			}
		}
		p[w+1]++;
	}
	int ans=0,w=0;
	for(int i=0;i<m;i++)
	{
		if(p[i]>ans)
		{
			ans=p[i];
			w=i;
		}
	}
	cout << w;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,m,a[102],k;
    cin>>n>>m;
    memset(a,0,sizeof(a));
    for(int i=0;i<m;i++)
    {
        for(int j=1;j<=n;j++)
        {
            cin>>k;
            a[j]=a[j]+k;
        }
    }
    int nu=0,ma=a[0];
    for(int i=1;i<=n;i++)
    {
        if(a[i]>ma)
        {
            ma=a[i];
            nu=i;
        }
    }
    cout<<nu;
    return 0;
}


#include <bits/stdc++.h>
#define il inline
#define re register
using namespace std;
typedef long long ll;
int n, m;
struct node {
	int p, id;
	il bool operator < (const node &a) const {
		if(p == a.p) return id < a.id;
		return p > a.p;
	}
}e[1010], ans[1010];
int main() {
	scanf("%d%d", &n, &m);
	for(re int i = 1; i <= m; ++i) {
		for(re int j = 1; j <= n; ++j) {
			scanf("%d", &e[j].p);
			e[j].id = j;
		}
		sort(e+1, e+n+1);
		ans[i].p = e[1].p;
		ans[i].id = e[1].id;
	}
	sort(ans+1, ans+m+1);
	printf("%d\n", ans[1].id);
	return 0;
}


#include<iostream>
using namespace std;
int n,m;
int a,zuiniubidehouxuanren;
int maxn,zuiniubidehouxuanrenmax;
int main(){
	cin>>n>>m;
	int c[n+1]={0};
	for(int i=1;i<=m;i++){
		zuiniubidehouxuanren=-1;
		zuiniubidehouxuanrenmax=-1;
		for(int j=1;j<=n;j++){
			cin>>a;
			if(a>zuiniubidehouxuanrenmax){
				zuiniubidehouxuanrenmax=a;
				zuiniubidehouxuanren=j;
			}
		}
		c[zuiniubidehouxuanren]++;
	}
	for(int i=1;i<=n;i++)if(c[i]>maxn)maxn=c[i];
	for(int i=1;i<=n;i++){
		if(c[i]==maxn){
			cout<<i;
			return 0;
		 }
	}
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tree_Queries
{
    class Node : IComparable
    {
        public int ID;
        public int appear;
        public List<Node> Childrens;
        public int level;
        public Node(int id)
        {
            ID = id;
            appear = 0;
            Childrens = new List<Node>();
            level = 0;
        }

        public int CompareTo(object obj)
        {
            Node node = (Node)obj;
            return level.CompareTo(node.level);
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            var x_0 = Console.ReadLine().Split();
            int nodes = int.Parse(x_0[0]);
            int queries = int.Parse(x_0[1]);
            Node[] nodes_list = new Node[nodes];
            List<Node>[] querie_list = new List<Node>[queries];
            for (int i = 0; i < nodes_list.Length; i++)
            {
                nodes_list[i] = new Node(i);
            }
            for (int i = 0; i < nodes - 1; i++)
            {
                var x = Console.ReadLine().Split();
                nodes_list[int.Parse(x[0]) - 1].Childrens.Add(nodes_list[int.Parse(x[1]) - 1]);
                nodes_list[int.Parse(x[1]) - 1].Childrens.Add(nodes_list[int.Parse(x[0]) - 1]);

            }
            for (int i = 0; i < queries; i++)
            {
                querie_list[i] = new List<Node>();
                var x = Console.ReadLine().Split();
                for (int j = 0; j < x.Length; j++)
                {
                    if (!querie_list[i].Contains(nodes_list[int.Parse(x[j]) - 1]))
                        querie_list[i].Add(nodes_list[int.Parse(x[j]) - 1]);
                }
            }
            Node[] Pi = new Node[nodes];
            Pi[0] = nodes_list[0];
            bool[] view = new bool[nodes];
            Queue<Node> visiting = new Queue<Node>();
            visiting.Enqueue(nodes_list[0]);
            view[0] = true;
            while (visiting.Count != 0)
            {
                Node temp = visiting.Dequeue();
                foreach (var X in temp.Childrens)
                {
                    if (!view[X.ID])
                    {
                        view[X.ID] = true;
                        Pi[X.ID] = temp;
                        X.level = temp.level + 1;
                        visiting.Enqueue(X);
                    }
                }
            }
            for (int i = 0; i < querie_list.Count(); i++)
            {
                querie_list[i].Sort();

                Node node = querie_list[i].Last();

                List<Node> way = new List<Node>();
                way.Add(node);
                while (node.ID != 0)
                {
                    node = Pi[node.ID];
                    way.Add(node);
                }
                bool temp = false;
                for (int j = 0; j < querie_list[i].Count()-1; j++)
                {
                    if (querie_list[i][j].ID == 0) continue;
                    querie_list[i][j] = Pi[querie_list[i][j].ID];
                }
                for (int j = 0; j < querie_list[i].Count(); j++)
                {
                    if (!way.Contains(querie_list[i][j]))
                    {
                        Console.WriteLine("No");
                        temp = true;
                    }
                }
                if (!temp) Console.WriteLine("Yes");
            }

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tree_Queries
{
    class Node : IComparable
    {
        public int ID;
        public int appear;
        public List<Node> Childrens;
        public int level;
        public Node(int id)
        {
            ID = id;
            appear = 0;
            Childrens = new List<Node>();
            level = 0;
        }

        public int CompareTo(object obj)
        {
            Node node = (Node)obj;
            return level.CompareTo(node.level);
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            var x_0 = Console.ReadLine().Split();
            int nodes = int.Parse(x_0[0]);
            int queries = int.Parse(x_0[1]);
            Node[] nodes_list = new Node[nodes];
            List<Node>[] querie_list = new List<Node>[queries];
            for (int i = 0; i < nodes_list.Length; i++)
            {
                nodes_list[i] = new Node(i);
            }
            for (int i = 0; i < nodes - 1; i++)
            {
                var x = Console.ReadLine().Split();
                nodes_list[int.Parse(x[0]) - 1].Childrens.Add(nodes_list[int.Parse(x[1]) - 1]);
                nodes_list[int.Parse(x[1]) - 1].Childrens.Add(nodes_list[int.Parse(x[0]) - 1]);

            }
            for (int i = 0; i < queries; i++)
            {
                querie_list[i] = new List<Node>();
                var x = Console.ReadLine().Split();
                for (int j = 0; j < x.Length; j++)
                {
                    if (!querie_list[i].Contains(nodes_list[int.Parse(x[j]) - 1]))
                        querie_list[i].Add(nodes_list[int.Parse(x[j]) - 1]);
                }
            }
            Node[] Pi = new Node[nodes];
            Pi[0] = nodes_list[0];
            bool[] view = new bool[nodes];
            Queue<Node> visiting = new Queue<Node>();
            visiting.Enqueue(nodes_list[0]);
            view[0] = true;
            while (visiting.Count != 0)
            {
                Node temp = visiting.Dequeue();
                foreach (var X in temp.Childrens)
                {
                    if (!view[X.ID])
                    {
                        view[X.ID] = true;
                        Pi[X.ID] = temp;
                        X.level = temp.level + 1;
                        visiting.Enqueue(X);
                    }
                }
            }
            for (int i = 0; i < querie_list.Count(); i++)
            {
                querie_list[i].Sort();

                Node node = querie_list[i].Last();
                querie_list[i].Remove(node);
                List<Node> way = new List<Node>();
                way.Add(node);
                while (node.ID != 0)
                {
                    node = Pi[node.ID];
                    way.Add(node);
                }
                bool temp = false;
                for (int j = 0; j < querie_list[i].Count(); j++)
                {
                    querie_list[i][j] = Pi[querie_list[i][j].ID];
                }
                for (int j = 0; j < querie_list[i].Count(); j++)
                {
                    if (!way.Contains(querie_list[i][j]))
                    {
                        Console.WriteLine("No");
                        temp = true;
                    }
                }
                if (!temp) Console.WriteLine("Yes");
            }

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tree_Queries
{
    class Node
    {
        public int ID;
        public int appear;
        public List<Node> Childrens;
        public int level;
        public Node(int id)
        {
            ID = id;
            appear = 0;
            Childrens = new List<Node>();
            level = 0;
        }

    }

    class Program
    {
        static int Find_Deepest(List<Node> nodes)
        {
            int index = 0;
            int max = 0;
            for (int i = 0; i < nodes.Count(); i++)
            {
                if (nodes[i].level > max)
                {
                    index = i;
                    max = nodes[i].level;
                }
            }
            return index;
        }

        static void Main(string[] args)
        {
            var x_0 = Console.ReadLine().Split();
            int nodes = int.Parse(x_0[0]);
            int queries = int.Parse(x_0[1]);
            Node[] nodes_list = new Node[nodes];
            List<Node>[] querie_list = new List<Node>[queries];
            for (int i = 0; i < nodes_list.Length; i++)
            {
                nodes_list[i] = new Node(i);
            }
            for (int i = 0; i < nodes - 1; i++)
            {
                var x = Console.ReadLine().Split();
                nodes_list[int.Parse(x[0]) - 1].Childrens.Add(nodes_list[int.Parse(x[1]) - 1]);
                nodes_list[int.Parse(x[1]) - 1].Childrens.Add(nodes_list[int.Parse(x[0]) - 1]);

            }
            for (int i = 0; i < queries; i++)
            {
                querie_list[i] = new List<Node>();
                var x = Console.ReadLine().Split();
                for (int j = 0; j < x.Length; j++)
                {
                   // if (!querie_list[i].Contains(nodes_list[int.Parse(x[j]) - 1]))
                        querie_list[i].Add(nodes_list[int.Parse(x[j]) - 1]);
                }
            }
            Node[] Pi = new Node[nodes];
            Pi[0] = nodes_list[0];
            bool[] view = new bool[nodes];
            Queue<Node> visiting = new Queue<Node>();
            visiting.Enqueue(nodes_list[0]);
            view[0] = true;
            while (visiting.Count != 0)
            {
                Node temp = visiting.Dequeue();
                foreach (var X in temp.Childrens)
                {
                    if (!view[X.ID])
                    {
                        view[X.ID] = true;
                        Pi[X.ID] = temp;
                        X.level = temp.level + 1;
                        visiting.Enqueue(X);
                    }
                }
            }
            for (int i = 0; i < querie_list.Count(); i++)
            {

                Node node = querie_list[i][Find_Deepest(querie_list[i])];
                Node f_v = querie_list[i][Find_Deepest(querie_list[i])];
                List<Node> way = new List<Node>();
                way.Add(node);
                while (node.ID != 0)
                {
                    node = Pi[node.ID];
                    way.Add(node);
                }
                bool temp = false;
                for (int j = 0; j < querie_list[i].Count(); j++)
                {
                    if (querie_list[i][j] == f_v) continue;
                    if (querie_list[i][j].ID == 0) continue;
                    querie_list[i][j] = Pi[querie_list[i][j].ID];
                }
                for (int j = 0; j < querie_list[i].Count(); j++)
                {
                    if (!way.Contains(querie_list[i][j]))
                    {
                        Console.WriteLine("No");
                        temp = true;
                    }
                }
                if (!temp) Console.WriteLine("Yes");
            }

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tree_Queries
{
    class Node
    {
        public int ID;
        public int appear;
        public List<Node> Childrens;
        public int level;
        public Node(int id)
        {
            ID = id;
            appear = 0;
            Childrens = new List<Node>();
            level = 0;
        }

    }

    class Program
    {
        static int Find_Deepest(List<Node> nodes)
        {
            int index = 0;
            int max = 0;
            for (int i = 0; i < nodes.Count(); i++)
            {
                if (nodes[i].level > max)
                {
                    index = i;
                    max = nodes[i].level;
                }
            }
            return index;
        }
        static bool Contains(List<Node> nodes , Node X)
        {
            foreach (var Y in nodes)
                if (Y.ID == X.ID) return true;
            return false;
        }

        static void Main(string[] args)
        {
            var x_0 = Console.ReadLine().Split();
            int nodes = int.Parse(x_0[0]);
            int queries = int.Parse(x_0[1]);
            Node[] nodes_list = new Node[nodes];
            List<Node>[] querie_list = new List<Node>[queries];
            for (int i = 0; i < nodes_list.Length; i++)
            {
                nodes_list[i] = new Node(i);
            }
            for (int i = 0; i < nodes - 1; i++)
            {
                var x = Console.ReadLine().Split();
                nodes_list[int.Parse(x[0]) - 1].Childrens.Add(nodes_list[int.Parse(x[1]) - 1]);
                nodes_list[int.Parse(x[1]) - 1].Childrens.Add(nodes_list[int.Parse(x[0]) - 1]);

            }
            for (int i = 0; i < queries; i++)
            {
                querie_list[i] = new List<Node>();
                var x = Console.ReadLine().Split();
                for (int j = 0; j < x.Length; j++)
                {
                        querie_list[i].Add(nodes_list[int.Parse(x[j]) - 1]);
                }
            }
            Node[] Pi = new Node[nodes];
            Pi[0] = nodes_list[0];
            bool[] view = new bool[nodes];
            Queue<Node> visiting = new Queue<Node>();
            visiting.Enqueue(nodes_list[0]);
            view[0] = true;
            while (visiting.Count != 0)
            {
                Node temp = visiting.Dequeue();
                foreach (var X in temp.Childrens)
                {
                    if (!view[X.ID])
                    {
                        view[X.ID] = true;
                        Pi[X.ID] = temp;
                        X.level = temp.level + 1;
                        visiting.Enqueue(X);
                    }
                }
            }
            for (int i = 0; i < querie_list.Count(); i++)
            {

                Node node = querie_list[i][Find_Deepest(querie_list[i])];
                Node f_v = querie_list[i][Find_Deepest(querie_list[i])];
                List<Node> way = new List<Node>();
                way.Add(node);
                while (node.ID != 0)
                {
                    node = Pi[node.ID];
                    way.Add(node);
                }
                bool temp = false;
                for (int j = 0; j < querie_list[i].Count(); j++)
                {
                    if (querie_list[i][j].ID == f_v.ID) continue;
                    if (querie_list[i][j].ID == 0) continue;
                    querie_list[i][j] = Pi[querie_list[i][j].ID];
                }
                for (int j = 0; j < querie_list[i].Count(); j++)
                {
                    if (!Contains(way, querie_list[i][j]))
                    {
                        Console.WriteLine("No");
                        temp = true;
                    }
                }
                if (!temp) Console.WriteLine("Yes");
            }

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tree_Queries
{
    class Node : IComparable
    {
        public int ID;
        public int appear;
        public List<Node> Childrens;
        public int level;
        public Node(int id)
        {
            ID = id;
            appear = 0;
            Childrens = new List<Node>();
            level = 0;
        }

        public int CompareTo(object obj)
        {
            Node node = (Node)obj;
            return level.CompareTo(node.level);
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            var x_0 = Console.ReadLine().Split();
            int nodes = int.Parse(x_0[0]);
            int queries = int.Parse(x_0[1]);
            Node[] nodes_list = new Node[nodes];
            List<Node>[] querie_list = new List<Node>[queries];
            for (int i = 0; i < nodes_list.Length; i++)
            {
                nodes_list[i] = new Node(i);
            }
            for (int i = 0; i < nodes - 1; i++)
            {
                var x = Console.ReadLine().Split();
                nodes_list[int.Parse(x[0]) - 1].Childrens.Add(nodes_list[int.Parse(x[1]) - 1]);
                nodes_list[int.Parse(x[1]) - 1].Childrens.Add(nodes_list[int.Parse(x[0]) - 1]);

            }
            for (int i = 0; i < queries; i++)
            {
                querie_list[i] = new List<Node>();
                var x = Console.ReadLine().Split();
                for (int j = 0; j < x.Length; j++)
                {
                    if (!querie_list[i].Contains(nodes_list[int.Parse(x[j]) - 1]))
                        querie_list[i].Add(nodes_list[int.Parse(x[j]) - 1]);
                }
            }
            Node[] Pi = new Node[nodes];
            Pi[0] = nodes_list[0];
            bool[] view = new bool[nodes];
            Queue<Node> visiting = new Queue<Node>();
            visiting.Enqueue(nodes_list[0]);
            view[0] = true;
            while (visiting.Count != 0)
            {
                Node temp = visiting.Dequeue();
                foreach (var X in temp.Childrens)
                {
                    if (!view[X.ID])
                    {
                        view[X.ID] = true;
                        Pi[X.ID] = temp;
                        X.level = temp.level + 1;
                        visiting.Enqueue(X);
                    }
                }
            }
            for (int i = 0; i < querie_list.Count(); i++)
            {
                querie_list[i].Sort();

                Node node = querie_list[i].Last();
                List<Node> way = new List<Node>();
                way.Add(node);
                while (node.ID != 0)
                {
                    node = Pi[node.ID];
                    way.Add(node);
                }
                bool temp = false;
                querie_list[i].RemoveAt(querie_list[i].Count - 1);
                foreach (var X in querie_list[i])
                {
                    if (!way.Contains(Pi[X.ID]))
                    {
                        temp = true;
                        Console.WriteLine("No");
                        break;
                    }
                }
                if (!temp) Console.WriteLine("Yes");
            }

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tree_Queries
{
    class Node : IComparable
    {
        public int ID;
        public int appear;
        public List<Node> Childrens;
        public int level;
        public Node(int id)
        {
            ID = id;
            appear = 0;
            Childrens = new List<Node>();
            level = 0;
        }

        public int CompareTo(object obj)
        {
            Node node = (Node)obj;
            return level.CompareTo(node.level);
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            var x_0 = Console.ReadLine().Split();
            int nodes = int.Parse(x_0[0]);
            int queries = int.Parse(x_0[1]);
            Node[] nodes_list = new Node[nodes];
            List<Node>[] querie_list = new List<Node>[queries];
            for (int i = 0; i < nodes_list.Length; i++)
            {
                nodes_list[i] = new Node(i);
            }
            for (int i = 0; i < nodes - 1; i++)
            {
                var x = Console.ReadLine().Split();
                nodes_list[int.Parse(x[0]) - 1].Childrens.Add(nodes_list[int.Parse(x[1]) - 1]);
                nodes_list[int.Parse(x[1]) - 1].Childrens.Add(nodes_list[int.Parse(x[0]) - 1]);

            }
            for (int i = 0; i < queries; i++)
            {
                querie_list[i] = new List<Node>();
                var x = Console.ReadLine().Split();
                for (int j = 0; j < x.Length; j++)
                {
                    if (!querie_list[i].Contains(nodes_list[int.Parse(x[j]) - 1]))
                        querie_list[i].Add(nodes_list[int.Parse(x[j]) - 1]);
                }
            }
            Node[] Pi = new Node[nodes];
            Pi[0] = nodes_list[0];
            bool[] view = new bool[nodes];
            Queue<Node> visiting = new Queue<Node>();
            visiting.Enqueue(nodes_list[0]);
            view[0] = true;
            while (visiting.Count != 0)
            {
                Node temp = visiting.Dequeue();
                foreach (var X in temp.Childrens)
                {
                    if (!view[X.ID])
                    {
                        view[X.ID] = true;
                        Pi[X.ID] = temp;
                        X.level = temp.level + 1;
                        visiting.Enqueue(X);
                    }
                }
            }
            for (int i = 0; i < querie_list.Count(); i++)
            {
                querie_list[i].Sort();
                querie_list[i].RemoveAt(querie_list[i].Count -1);
                Node node = querie_list[i].Last();
                List<Node> way = new List<Node>();
                way.Add(node);
                while (node.ID != 0)
                {
                    node = Pi[node.ID];
                    way.Add(node);
                }
                bool temp = false;
                foreach (var X in querie_list[i])
                {
                    if (!way.Contains(Pi[X.ID]))
                    {
                        temp = true;
                        Console.WriteLine("No");
                        break;
                    }
                }
                if (!temp) Console.WriteLine("Yes");
            }

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tree_Queries
{
    class Node
    {
        public int ID;
        public int appear;
        public List<Node> Childrens;
        public int level;
        public Node(int id)
        {
            ID = id;
            appear = 0;
            Childrens = new List<Node>();
            level = 0;
        }

    }

    class Program
    {
        static int Find_Deepest(List<Node> nodes)
        {
            int index = 0;
            int max = 0;
            for (int i = 0; i < nodes.Count(); i++)
            {
                if (nodes[i].level > max)
                {
                    index = i;
                    max = nodes[i].level;
                }
            }
            return index;
        }
        static bool Contains(List<Node> nodes , Node X, Node[] Pi)
        {
            foreach (var Y in nodes)
                if (Y.ID == X.ID) return true;
            foreach (var Y in nodes)
                if (Pi[X.ID].ID == Y.ID) return true;

            return false;
        }

        static void Main(string[] args)
        {
            var x_0 = Console.ReadLine().Split();
            int nodes = int.Parse(x_0[0]);
            int queries = int.Parse(x_0[1]);
            Node[] nodes_list = new Node[nodes];
            List<Node>[] querie_list = new List<Node>[queries];
            for (int i = 0; i < nodes_list.Length; i++)
            {
                nodes_list[i] = new Node(i);
            }
            for (int i = 0; i < nodes - 1; i++)
            {
                var x = Console.ReadLine().Split();
                nodes_list[int.Parse(x[0]) - 1].Childrens.Add(nodes_list[int.Parse(x[1]) - 1]);
                nodes_list[int.Parse(x[1]) - 1].Childrens.Add(nodes_list[int.Parse(x[0]) - 1]);

            }
            for (int i = 0; i < queries; i++)
            {
                querie_list[i] = new List<Node>();
                var x = Console.ReadLine().Split();
                for (int j = 1; j < x.Length; j++)
                {
                        querie_list[i].Add(nodes_list[int.Parse(x[j]) - 1]);
                }
            }
            Node[] Pi = new Node[nodes];
            Pi[0] = nodes_list[0];
            bool[] view = new bool[nodes];
            Queue<Node> visiting = new Queue<Node>();
            visiting.Enqueue(nodes_list[0]);
            view[0] = true;
            while (visiting.Count != 0)
            {
                Node temp = visiting.Dequeue();
                foreach (var X in temp.Childrens)
                {
                    if (!view[X.ID])
                    {
                        view[X.ID] = true;
                        Pi[X.ID] = temp;
                        X.level = temp.level + 1;
                        visiting.Enqueue(X);
                    }
                }
            }
            for (int i = 0; i < querie_list.Count(); i++)
            {

                Node node = querie_list[i][Find_Deepest(querie_list[i])];
                Node f_v = querie_list[i][Find_Deepest(querie_list[i])];
                List<Node> way = new List<Node>();
                way.Add(node);
                while (node.ID != 0)
                {
                    node = Pi[node.ID];
                    way.Add(node);
                }
                bool temp = false;

                for (int j = 0; j < querie_list[i].Count(); j++)
                {
                    if (!Contains(way, querie_list[i][j], Pi))
                    {
                        Console.WriteLine("No");
                        temp = true;
                        break;
                    }
                }
                if (!temp) Console.WriteLine("Yes");
            }

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Valera_and_Elections
{

    class Program
    {
        static bool DFS(int node, List<int>[]tree, bool[] need_repair, bool[] visited)
        {

            visited[node] = true;
            bool status = need_repair[node];
            foreach (var son in tree[node].Where(X => !visited[X]))
            {
                if(DFS(son, tree, need_repair, visited))
                {
                    need_repair[node] = false;
                    status = true;
                }
            }
            return status;
        }
        static void Main(string[] args)
        {
            var regions_count = int.Parse(Console.ReadLine());
            List<int>[]regions = new List<int>[regions_count];
            bool[] need_repair = new bool[regions_count];
            for (int i = 0; i < regions.Length; i++)
            {
                regions[i] = new List<int>();
            }
            for (int i = 0; i < regions_count-1; i++)
            {
                var edge = Console.ReadLine().Split();
                regions[int.Parse(edge[0]) - 1].Add(int.Parse(edge[1]) - 1);
                regions[int.Parse(edge[1]) - 1].Add(int.Parse(edge[0]) - 1);
                need_repair[int.Parse(edge[0]) - 1] |= int.Parse(edge[2]) == 2 ;
                need_repair[int.Parse(edge[1]) - 1] |= int.Parse(edge[2]) == 2 ;

            }
            bool[] visited = new bool[regions_count];
            visited[0] = true;
            need_repair[0]=false;
            DFS(0, regions, need_repair, visited);
            List<int> solution = new List<int>();
            for (int i = 0; i < need_repair.Count(); i++)
            {
                if(need_repair[i])solution.Add(i+1);
            }
            Console.WriteLine(solution.Count());
            Console.WriteLine(string.Join(" ",solution));
        }
	}

}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tree_Queries
{

    class Program
    {

        static void Main(string[] args)
        {
            var line_0 = Console.ReadLine().Split();
            List<int>[] nodes = new List<int>[int.Parse(line_0[0])];
            for (int i = 0; i < nodes.Length; i++)
            {
                nodes[i] = new List<int>();
            }
            for (int i = 0; i < int.Parse(line_0[0]) - 1; i++)
            {
                var edge = Console.ReadLine().Split();
                nodes[int.Parse(edge[0]) - 1].Add(int.Parse(edge[1]) - 1);
                nodes[int.Parse(edge[1]) - 1].Add(int.Parse(edge[0]) - 1);
            }
            List<int>[] queries = new List<int>[int.Parse(line_0[1])];
            for (int i = 0; i < queries.Length; i++)
            {
                queries[i] = new List<int>();
                var querie = Console.ReadLine().Split();
                for (int j = 1; j < querie.Length; j++)
                {
                    queries[i].Add(int.Parse(querie[j]) - 1);
                }
            }
            int[] Pi = new int[nodes.Length];
            int[] deep = new int[nodes.Length];
            int bfs_index = 0;
            bool[] visited = new bool[int.Parse(line_0[0])];
            Queue<int> Visiting = new Queue<int>();
            Visiting.Enqueue(bfs_index);
            visited[bfs_index] = true;
            while(Visiting.Count() != 0)
            {
                bfs_index = Visiting.Dequeue();
                for (int i = 0; i < nodes[bfs_index].Count(); i++)
                {
                    if (!visited[nodes[bfs_index][i]])
                    {
                        deep[nodes[bfs_index][i]] = deep[bfs_index] + 1;
                        visited[nodes[bfs_index][i]] = true;
                        Pi[nodes[bfs_index][i]] = bfs_index;
                        Visiting.Enqueue(nodes[bfs_index][i]);
                    }
                }
            }
            for (int i = 0; i < queries.Length; i++)
            {
                int f_v = Find_Deepest(deep, queries[i]);
                List<int> way = new List<int>();
                way.Add(f_v);
                int node = f_v;
                while(node != 0)
                {
                    node = Pi[node];
                    way.Add(node);
                }
                bool temp = true;
                for (int j = 0; j < queries[i].Count(); j++)
                {
                    if (queries[i][j] == f_v) continue;
                    if (queries[i][j] == 0) continue;
                    if (!way.Contains(Pi[queries[i][j]]))
                    {
                        temp = false;
                        Console.WriteLine("No");
                        break;
                    }
                }
                if (temp) Console.WriteLine("Yes");
            }
        }

        static int Find_Deepest(int[] deep, List<int> list)
        {
            int deepest = 0;
            int max = 0;
            for (int i = 0; i < list.Count(); i++)
            {
                if(deep[list[i]] > max)
                {
                    max = deep[list[i]];
                    deepest = list[i];
                }
            }
            return deepest;
        }
    }
}