#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,popcnt,tune=native")
#pragma GCC target("avx,avx2")
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <iomanip>
#include <cassert>
#include <unordered_map>
#include <random>
#include <unordered_set>

#define all(x) x.begin(), x.end()
#define siz(x) (int)(x.size())

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
int n, k;
bool ok(int diam) {
    int have = n - diam - k + 2;
    int md = (diam) / 2 + diam % 2 - 1;
    //cout << "cnt of vrts: " << diam << ", ost: " << have << "\n";
    for (int i = 0; i < k - 2; ++i) {
        int d = min(have, md - 1);
        // cout << d << " vert for lev\n";
        have -= d;
    }
    return have == 0;
}
int bins() {
    int l = 2, r = n - k + 2, mi = 0;
    while (r - l > 1) {
        mi = (r + l) / 2;
        if (ok(mi))r = mi;
        else l = mi;
    }
    return r;
}
void print(vector<int>& a) {
    for (int x : a)cout << x << " ";
    cout << "\n";
}
void fill(vector<int>& fre, vector<int>& lev) {
    for (int i = 1; i <= n; ++i) {
        if (lev.size() < k)lev.push_back(i);
        else fre.push_back(i);
    }
}
int pop(vector<int>& a) {
    int x = a.back();
    a.pop_back();
    return x;
}
int main() {
    cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(0);
    cin >> n >> k;
    // cout << ok(5);
    // exit(0);
    int len = bins();
    vector<int>fre, lev;
    fill(fre, lev);
    //cout << "lev: "; print(lev);
    vector<int>ord(1, pop(lev));
    while (ord.size() + 1 < len) {
        ord.push_back(pop(fre));
    }
    ord.push_back(pop(lev));
    vector<pll>ans;
    //cout << "ord: "; print(ord);
    int have = n - len - k + 2;
    int md = len / 2 + len % 2 - 1;
    for (int x : lev) {
        int cnt = min(have, md - 1);
        int v = ord[md];
        have -= cnt;
        //cout << "for leave " << x << " need " << cnt << " vertices\n";
        while (cnt > 0) {
            ans.push_back({ v, fre.back() });
            v = pop(fre);
            --cnt;
        }
        ans.push_back({ v, x });
    }
    for (int i = 1; i < ord.size(); ++i)ans.push_back({ ord[i], ord[i - 1] });
    //cout << (ans.size() == n - 1);
    assert(siz(ans) == n - 1);
    cout << len - 1 << "\n";
    for (auto pp : ans)cout << pp.first << " " << pp.second << "\n";
    return 0;
}/*
 7 3
 6 3

 5 3

 */


#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,popcnt,tune=native")
#pragma GCC target("avx,avx2")
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <iomanip>
#include <cassert>
#include <unordered_map>
#include <random>
#include <unordered_set>

#define all(x) x.begin(), x.end()
#define siz(x) (int)(x.size())

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
int n, k;
bool ok(int len) {
    int have = n - len - k + 2;
    int mx = (len+1) / 2 - 2;
    //cout << "cnt of vrts: " << len << ", ost: " << have << "\n";
    for (int i = 0; i < k - 2; ++i) {
        int d = max(0, min(have, mx));
       // cout << d << " vert for lev\n";
        have -= d;
    }
    return have == 0;
}
int bins() {
    int l = 2, r = n - k + 2, mi = 0;
    while (r - l > 1) {
        mi = (r + l) / 2;
        if (ok(mi))r = mi;
        else l = mi;
    }
    return r;
}
void print(vector<int>& a) {
    for (int x : a)cout << x << " ";
    cout << "\n";
}
void fill(vector<int>& fre, vector<int>& lev) {
    for (int i = 1; i <= n; ++i) {
        if (lev.size() < k)lev.push_back(i);
        else fre.push_back(i);
    }
}
int pop(vector<int>& a) {
    int x = a.back();
    a.pop_back();
    return x;
}
int main() {
    cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(0);
    cin >> n >> k;
   // cout << ok(5);
   // exit(0);
    int len =  bins();
    vector<int>fre, lev;
    fill(fre, lev);
    //cout << "lev: "; print(lev);
    vector<int>ord(1, pop(lev));
    while (ord.size() + 1 < len) {
        ord.push_back(pop(fre));
    }
    ord.push_back(pop(lev));
    vector<pll>ans;
    //cout << "ord: "; print(ord);
    int have = n - len - k + 2;
    int md = len / 2;
    for (int x : lev) {
        int cnt = min(have, md - 1);
        int v = ord[md];
        have -= cnt;
        //cout << "for leave " << x << " need " << cnt << " vertices\n";
        while (cnt > 0) {
            ans.push_back({ v, fre.back() });
            v = pop(fre);
            --cnt;
        }
        ans.push_back({ v, x });
    }
    for (int i = 1; i < ord.size(); ++i)ans.push_back({ ord[i], ord[i - 1] });
    //cout << (ans.size() == n - 1);
    assert(siz(ans) == n - 1);
    cout << len - 1 << "\n";
    for (auto pp : ans)cout << pp.first << " " << pp.second << "\n";
    return 0;
}/*
 7 3
 6 3

 5 3

 */


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define sz(v) int((v).size())
#define int ll
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define mt make_tuple

int n, k;
void solve()
{
    scanf("%lld%lld", &n, &k);
    int dist = 2* (n-1)/k;
    if ((n-1)%k) ++dist;
    printf("%lld\n", dist);
    for (int i=1;i<n;++i)
    {
        int u = i;
        int v = max(i-k, 0LL);
        printf("%lld %lld\n", u+1,v+1);
    }
}
signed main()
{
    int T = 1; //scanf("%lld", &T);
    while (T--)
        solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define sz(v) int((v).size())
#define int ll
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define mt make_tuple

int n, k;
void solve()
{
    scanf("%lld%lld", &n, &k);
    int dist = (n-1)/k * 2;
    if ((n-1)%k) ++dist;
    printf("%lld\n", dist);
    for (int i=1;i<n;++i)
    {
        int u = i;
        int v = max(i-k, 0LL);
        printf("%lld %lld\n", u+1,v+1);
    }
}
signed main()
{
    int T = 1; //scanf("%lld", &T);
    while (T--)
        solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define sz(v) int((v).size())
#define int ll
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define mt make_tuple

int n, k;
void solve()
{
    scanf("%lld%lld", &n, &k);
    int dist = (n-1)/k * 2;
    if ((n-1)%k == 1) ++dist;
    else if ((n-1)%k >= 2)dist+=2;
    printf("%lld\n", dist);
    for (int i=1;i<n;++i)
    {
        int u = i;
        int v = max(i-k, 0LL);
        printf("%lld %lld\n", u+1,v+1);
    }
}
signed main()
{
    int T = 1; //scanf("%lld", &T);
    while (T--)
        solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define sz(v) int((v).size())
#define int ll
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define mt make_tuple

int n, k;
void solve()
{
    scanf("%lld%lld", &n, &k);
    int delta = n-k;
    printf("%lld\n", delta+1);
    for (int i = 1; i < delta;++i)
    {
        printf("%lld %lld\n", i, i+1);
    }
    printf("%lld %lld\n", 1, delta+1);
    for (int i=delta+2; i<=n;++i)
    {
        printf("%lld %lld\n", i, delta);
    }
}
signed main()
{
    int T = 1; //scanf("%lld", &T);
    while (T--)
        solve();
    return 0;
}


#include <bits/stdc++.h>

#define f(i,a,b) for( ll i = a; i < (ll) b ; i++ )
#define af(i,a,b) for( ll i = a; i >= (ll) b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < (ll) b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= (ll) b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nuintptr)
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;

const ll MAX = 1e6+10;
const ll inf = 1e9;

vi adj[MAX];

void dfs(ll u,ll f){
	f(i,0,adj[u].size()){
		ll v=adj[u][i];
		if(v==f) continue;
		cout<<u<<" "<<v<<endl;
		dfs(v,u);
	}
}
int main(){
	fastio;
	ll n,k;
	cin>>n>>k;
	if((n-1)%k==0) cout<<2*(n-1)/k<<endl;
	else if((n-1)%k==1) cout<<2*(n-1)/k +1<<endl;
	else cout<<2*(n-1)/k + 2 <<endl;
	f(i,2,k+2){
		adj[1].push_back(i);
		adj[i].push_back(1);
	}
	f(i,k+2,n+1){
		adj[i-k].push_back(i);
		adj[i].push_back(i-k);
	}
	dfs(1,0);
}


#include <bits/stdc++.h>

#define f(i,a,b) for( ll i = a; i < (ll) b ; i++ )
#define af(i,a,b) for( ll i = a; i >= (ll) b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < (ll) b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= (ll) b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nuintptr)
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;

const ll MAX = 1e6+10;
const ll inf = 1e9;

vi adj[MAX];

void dfs(ll u,ll f){
	f(i,0,adj[u].size()){
		ll v=adj[u][i];
		if(v==f) continue;
		cout<<u<<" "<<v<<endl;
		dfs(v,u);
	}
}
int main(){
	fastio;
	ll n,k;
	cin>>n>>k;
	if((n-1)%k==0) cout<<2*((n-1)/k)<<endl;
	else if((n-1)%k==1) cout<<2*((n-1)/k) +1<<endl;
	else cout<<2*((n-1)/k )+ 2 <<endl;
	f(i,2,k+2){
		adj[1].push_back(i);
		adj[i].push_back(1);
	}
	f(i,k+2,n+1){
		adj[i-k].push_back(i);
		adj[i].push_back(i-k);
	}
	dfs(1,0);
}


#include <bits/stdc++.h>

#define f(i,a,b) for( ll i = a; i < (ll) b ; i++ )
#define af(i,a,b) for( ll i = a; i >= (ll) b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < (ll) b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= (ll) b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nuintptr)
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;

const ll MAX = 1e6+10;
const ll inf = 1e9;

vi adj[MAX];

void dfs(ll u,ll f){
	f(i,0,adj[u].size()){
		ll v=adj[u][i];
		if(v==f) continue;
		cout<<u<<" "<<v<<endl;
		dfs(v,u);
	}
}
int main(){
	fastio;
	ll n,k;
	cin>>n>>k;
	cout<<n-k+1<<endl;
	f(i,1,n-k+2){
		adj[i].push_back(i+1);
		adj[i+1].push_back(i);
	}
	af(i,n,n-k+3){
		adj[2].push_back(i);
		adj[i].push_back(2);
	}
	dfs(1,0);
}


#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ull =  unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll, ll>;
int debug;
#define dout if(debug) cout
#define M_PI acos(-1.)
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()

int const MAXN = 1e6+5;
int const MAXA = 2e5+3;
int const INF = 1e9;
ll const LLINF = 1e17;
ll const MOD = 1e9+7;
double const EPS = 1e-9;
bool TESTS = false;

void no()
{
    cout << -1 << endl;
    exit(0);
}

void solve(){
    int n, k;
    cin >> n >> k;
    vector<pii> ans;
    int need = n-k-1;
    for(int i = 2, j = 0; j < min(n-k-1, k); i++, j++) {
        ans.pb({1, i});
        need--;
    }
    if(need) {
        int x = 1 + k;
        while (need) {
            x++;
            ans.pb({x - k, x});
            need--;
        }
        for(int i = x + 1, j = 0; j < k; j++, i++, x--)
            ans.pb({i, x});
        cout << ((n-k-1)%k==0?2*((n-k-1)/k+1):2*((n-k-1)/k+1)+1) << endl;
        for(auto u: ans)
            cout << u.first << " " << u.second << endl;

    }
    else{
        int x = n - k + 1;
        for(int i = 1; i <= n - k - 1; i++)
        {
            ans.pb({i+1, x});
            x++;
        }
        k -= n - k - 1;
        while(k){
            k--;
            ans.pb({1, x});
            x++;
        }
        cout << (n==1?2:3) << endl;
        for(auto u: ans)
            cout << u.first << " " << u.second << endl;
    }

}

int main()
{

#ifdef SOLVED
    debug = 1;
    freopen("in.txt", "r", stdin);
#elif defined(FILE)
    freopen("area.in", "r", stdin);
    freopen("area.out", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);

    int t = 1;
    if(TESTS) cin >> t;
    while(t-->0) solve();

    return 0;
}


#include <bits/stdc++.h>

#define fi first
#define se second
#define fin(s) freopen( s, "r", stdin );
#define fout(s) freopen( s, "w", stdout );

const long long N = 200010;
const long long mod = 1e9 + 7;

using namespace std;

int n;
int k;
int cnt;
int d[N];

void solve()
{
        cin >> n >> k;
        for(int i = 1; i <= k; i++){
                d[i - 1]++;
                cnt++;
        }
        for(int i = 2; i <= n; i++){
                if(i + k <= n){
                        d[(i - 2) % k]++;
                        cnt++;
                }
        }
        cout << d[0] + d[1] << "\n";
        assert(cnt == n - 1);
        for(int i = 1; i <= k; i++){
                cout << 1 << " " << i + 1 << "\n";
        }
        for(int i = 2; i <= n; i++){
                if(i + k <= n){
                        cout << i << " " << i + k << "\n";
                }
        }
}

bool mtest = false; int main()
{
        //fin("input.txt");
        //fout("output.txt");
        //fin("landscape.in");
        //fout("landscape.out");
        ios_base::sync_with_stdio(0);
        int TE = 1;
        if(mtest)
                cin >> TE;
        while(TE--)
                solve();
        return 0;
}


#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ull =  unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll, ll>;
int debug;
#define dout if(debug) cout
#define M_PI acos(-1.)
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()

int const MAXN = 1e6+5;
int const MAXA = 2e5+3;
int const INF = 1e9;
ll const LLINF = 1e17;
ll const MOD = 1e9+7;
double const EPS = 1e-9;
bool TESTS = false;

void no()
{
    cout << -1 << endl;
    exit(0);
}

void solve(){
    int n, k;
    cin >> n >> k;
    vector<pii> ans;
    int need = n-k-1;
    for(int i = 2, j = 0; j < min(n-k-1, k); i++, j++) {
        ans.pb({1, i});
        need--;
    }
    if(need) {
        int x = 1 + k;
        while (need) {
            x++;
            ans.pb({x - k, x});
            need--;
        }
        for(int i = x + 1, j = 0; j < k; j++, i++, x--)
            ans.pb({i, x});
        cout << ((n-k-1)%k==0?2*((n-k-1)/k+1):2*((n-k-1)/k+1)+1) << endl;
        for(auto u: ans)
            cout << u.first << " " << u.second << endl;

    }
    else{
        int x = n - k + 1; int t = n - k;
        for(int i = 1; i <= n - k - 1; i++)
        {
            ans.pb({i+1, x});
            x++;
        }
        k -= n - k - 1;
        while(k){
            k--;
            ans.pb({1, x});
            x++;
        }
        cout << (t==1?2:3) << endl;
        for(auto u: ans)
            cout << u.first << " " << u.second << endl;
    }

}

int main()
{

#ifdef SOLVED
    debug = 1;
    freopen("in.txt", "r", stdin);
#elif defined(FILE)
    freopen("area.in", "r", stdin);
    freopen("area.out", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);

    int t = 1;
    if(TESTS) cin >> t;
    while(t-->0) solve();

    return 0;
}


/*
কেন পান্থ! ক্ষান্ত হও হেরে দীর্ঘ পথ?
উদ্যম বিহনে কার পূরে মনোরথ,
কাঁটা হেরি ক্ষান্ত কেন কমল তুলিতে,
দুঃখ বিনা সুখ লাভ হয় কি মহীতে?

 - কৃষ্ণচন্দ্র মজুমদার
*/

/*
          ঘরে থাকুন , সুস্থ থাকুন ।
    stay home , stay safe .
    wan-_-s
*/
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define stay_home_stay_safe return 0
#define pb push_back
#define __ ios_base::sync_with_stdio(false); cin.tie(NULL);

void scan(ll &n) { scanf("%lld",&n) ; }
void scan(ll &n, ll &m) { scanf("%lld%lld",&n,&m) ; }
void scan(vector<ll> &v) { ll n = v.size() ; for(ll i=0 ;i<n;i++) scanf("%lld",&v[i]) ; }

/// const ll N = 200007 ;
/// vector<ll> adj[N] ;
/// void edge (ll u , ll v) {    adj[u].pb(v) ;    adj[v].pb(u) ; }
const int N = 2000007 ;
void solve() {
     ll n , k ;
     cin >> n >> k ;
     ll two = (n-k) , i ;
     cout << two + 1 << '\n' ;
     vector<pair<ll,ll> >ans ;
    for (i = 1 ; i< two ; i++) {
            ans.pb({i,i+1}) ;
    }
    ans.pb({1,two+1}) ;
    for (i = two + 2 ; i<= n ; i++) ans.pb({two,i}) ;

    for (auto it : ans) cout << it.first <<' ' << it.second << '\n' ;

}

int main() {
    __ ;
    int t = 1 ;
  //  cin >> t ;
    while(t--) { solve() ;}
    stay_home_stay_safe ;
}


/*
কেন পান্থ! ক্ষান্ত হও হেরে দীর্ঘ পথ?
উদ্যম বিহনে কার পূরে মনোরথ,
কাঁটা হেরি ক্ষান্ত কেন কমল তুলিতে,
দুঃখ বিনা সুখ লাভ হয় কি মহীতে?

 - কৃষ্ণচন্দ্র মজুমদার
*/

/*
          ঘরে থাকুন , সুস্থ থাকুন ।
    stay home , stay safe .
    wan-_-s
*/
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define stay_home_stay_safe return 0
#define pb push_back
#define __ ios_base::sync_with_stdio(false); cin.tie(NULL);

void scan(ll &n) { scanf("%lld",&n) ; }
void scan(ll &n, ll &m) { scanf("%lld%lld",&n,&m) ; }
void scan(vector<ll> &v) { ll n = v.size() ; for(ll i=0 ;i<n;i++) scanf("%lld",&v[i]) ; }

/// const ll N = 200007 ;
/// vector<ll> adj[N] ;
/// void edge (ll u , ll v) {    adj[u].pb(v) ;    adj[v].pb(u) ; }
const int N = 2000007 ;
void solve() {
     ll n , k ;
     cin >> n >> k ;
     ll two = (n-k) , i ;
     cout << (two>1 ? 3 : 2) << '\n' ;
     vector<pair<ll,ll> >ans ;
    for (i = 2 ; i<= two ; i++) {
            ans.pb({1,i}) ;
    }
    ll now = two + 1 ;
    for ( i = 2 ; i< two ; i++) {
        ans.pb({i,now++}) ;
    }
    while(now<=n) {
        ans.pb({two,now++}) ;
    }

    for (auto it : ans) cout << it.first <<' ' << it.second << '\n' ;

}

int main() {
    __ ;
    int t = 1 ;
  //  cin >> t ;
    while(t--) { solve() ;}
    stay_home_stay_safe ;
}


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

namespace CodeForces_570A_Elections
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] n = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int[] city;
            int[] candidate_of_city = new int[n[1]];
            int[] second_stage = new int[n[0]];
            int winner;
            for(int i=0;i<n[1];i++)
            {
                city= Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

                candidate_of_city[i] = Array.IndexOf(city, city.Max());

            }
            for(int i=0;i<n[0];i++)
            {
                second_stage[i] = candidate_of_city.Count(x => x == i);

            }
            winner = Array.IndexOf(second_stage, second_stage.Max())+1;
            Console.WriteLine(winner);
        }
    }
}


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

namespace Tests
{
    static class Program
    {

        internal static void MyMain()
        {
            int n, m;
            RInts(out n, out m);
            int[] cityWon = new int[n];
            for (int i = 0; i < m; i++)
            {
                List<int> city = RInts().ToList();
                var index = city.IndexOf(city.Max());
                cityWon[index]++;
            }

            var index2 = cityWon.ToList().IndexOf(cityWon.Max());

            WLine(index2+1);

        }
        static void Main(string[] args)
        {

#if !HOME
            MyMain();
#else
            Secret.MyMain();
#endif
        }

        #region Utils
        static string RLine()
        {
            return Console.ReadLine();
        }

        static string[] RLine(string separator = " ")
        {
            return Console.ReadLine().Split(new string[] { separator }, StringSplitOptions.None);
        }

        static int RInt()
        {
            var str = Console.ReadLine();
            return Convert.ToInt32(str);
        }
        static int[] RInts()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), s => Convert.ToInt32(s));
        }
        static void RInts(out int a, out int b)
        {
            var ints = RInts();
            a = ints[0];
            b = ints[1];
        }

        public static void WLine<T>(T s)
        {
            Console.WriteLine(s);
        }
        #endregion

    }
}


//Compile: `mono-csc file.cs`.

using System;
using System.Linq;
using System.Collections.Generic;

public class HelloWorld
{
        static public void Main ()
            {
		    int[] R = Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToArray();
		    int n = R[0]; // ncand
		    int m = R[1]; // ncities

		   var cities = new List<int[]>();

		   for(int i = 0; i < m; ++i)
		   {
			    R = Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToArray();
			    cities.Add( R );
		   }

		   int iWin = -1;
		   int mx = -1;
		   int[] indexOfCandidateForCity = new int[m];
		   for(int i = 0; i < m; ++i)
		   {
			   iWin = -1;
			   mx = -1;
			   for(int j = 0; j < n; ++j)
			   {
				   if(cities[i][j] > mx)
				   {
					   mx = cities[i][j];
					   iWin = j;
				   }
			   }

			   indexOfCandidateForCity[i] = iWin;
		   }

		   // cand #, nwin
		   var occur = new Dictionary<int, int>();
		   foreach(int v in indexOfCandidateForCity)
		   {
			   if(!occur.ContainsKey(v)) occur[v] = 0;
			   occur[v]+=1;
		   }

		   iWin = int.MaxValue;
		   mx = -1;
		   foreach(var kvp in occur)
		   {
			   if(kvp.Value >= mx)
			   {
				   if(kvp.Key < iWin)
				   {
					   iWin = kvp.Key;
					   mx = kvp.Value;
				   }
			   }
		   }

		Console.WriteLine (iWin+1);
            }
}


//Compile: `mono-csc file.cs`.

using System;
using System.Linq;
using System.Collections.Generic;

public class HelloWorld
{
        static public void Main ()
            {
		    int[] R = Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToArray();
		    int n = R[0]; // ncand
		    int m = R[1]; // ncities

		   var cities = new List<int[]>();

		   for(int i = 0; i < m; ++i)
		   {
			    R = Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToArray();
			    cities.Add( R );
		   }

		   int iWin = -1;
		   int mx = -1;
		   int[] indexOfCandidateForCity = new int[m];
		   for(int i = 0; i < m; ++i)
		   {
			   iWin = -1;
			   mx = -1;
			   for(int j = 0; j < n; ++j)
			   {
				   if(cities[i][j] > mx)
				   {
					   mx = cities[i][j];
					   iWin = j;
				   }
			   }

			   indexOfCandidateForCity[i] = iWin;
		   }

		   // cand #, nwin
		   var occur = new Dictionary<int, int>();
		   foreach(int v in indexOfCandidateForCity)
		   {
			   if(!occur.ContainsKey(v)) occur[v] = 0;
			   occur[v]+=1;
		   }

		   iWin = int.MaxValue;
		   mx = -1;
		   foreach(var kvp in occur)
		   {
			   if(kvp.Value > mx)
			   {
				   iWin = kvp.Key;
				   mx = kvp.Value;
			   }

			   if(kvp.Value==mx && kvp.Key < iWin)
			   {
				   iWin = kvp.Key;
				   mx = kvp.Value;
			   }
		   }

		Console.WriteLine (iWin+1);
            }
}


using System;
using System.IO;
using System.Text;

namespace Elections
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            int m = Next();
            int n = Next();

            var nn = new int[n,m + 1];
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < m; j++)
                {
                    nn[i, j] = Next();
                }
            }

            for (int i = 0; i < n; i++)
            {
                int min = 0;
                for (int j = 1; j < m; j++)
                {
                    if (nn[i, min] < nn[i, j])
                        min = j;
                }
                nn[i, m] = min;
            }

            var counts = new int[m];
            for (int i = 0; i < n; i++)
            {
                counts[nn[i, m]]++;
            }

            int max = 0;
            for (int i = 1; i < m; i++)
            {
                if (counts[i] > counts[max])
                    max = i;
            }

            writer.WriteLine(max + 1);
            writer.Flush();
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}


using System;
using System.IO;
using System.Text;

namespace Elections
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            int m = Next();
            int n = Next();

            var nn = new int[n,m + 1];
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < m; j++)
                {
                    nn[i, j] = Next();
                }
            }

            for (int i = 0; i < n; i++)
            {
                int min = 0;
                for (int j = 1; j < m; j++)
                {
                    if (nn[i, min] < nn[i, j])
                        min = j;
                }
                nn[i, m] = min;
            }

            var counts = new int[n];
            for (int i = 0; i < n; i++)
            {
                counts[nn[i, m]]++;
            }

            int max = 0;
            for (int i = 1; i < n; i++)
            {
                if (counts[i] > counts[max])
                    max = i;
            }

            writer.WriteLine(max + 1);
            writer.Flush();
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}


using System;

namespace ConsoleApplication1
{
    internal class Program
    {
        private static string s;

        private static string[] t;

        private static void Main(string[] args)
        {
            t = Console.ReadLine().Split(' ');

            int n = int.Parse(t[0]),
                m = int.Parse(t[1]);

            var a = new int[m, n];

            for (int i = 0; i < m; i++)
            {
                t = Console.ReadLine().Split(' ');

                for (int j = 0; j < n; j++)
                {
                    a[i, j] = int.Parse(t[j]);
                }
            }

            var b = new int[n];

            for (int i = 0; i < m; i++)
            {
                var max = int.MinValue;
                var maxInd = -1;

                for (int j = 0; j < n; j++)
                {
                    if (a[i, j] > max)
                    {
                        max = a[i, j];
                        maxInd = j;
                    }
                }

                b[maxInd]++;
            }

            var Max = int.MinValue;
            var MaxInd = -1;

            for (int i = 0; i < n; i++)
            {
                if (b[i] > Max)
                {
                    Max = b[i];
                    MaxInd = i;
                }
            }

            Console.WriteLine(MaxInd + 1);
        }
    }
}


using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main()
        {
           // string n = Console.ReadLine();

            string foo = Console.ReadLine();
            string[] tokens = foo.Split(' ');
            int[] nm = new int[2];
            int j = 0;
            foreach (var i in tokens)
            {
                nm[j ++] = Convert.ToInt32(i);
            }

            int n = nm[0];
            int m = nm[1];

            int[,] mas = new int[m,n];

            for (int i = 0; i < m; i++)
            {
                foo = Console.ReadLine();
                tokens = foo.Split(' ');

                for (int z = 0; z < n; z++)
                {
                    mas[i, z] = Convert.ToInt32(tokens[z]);
                }
            }

            int[] cits = new int[m];

            for (int i = 0; i < m; i++)
            {
                int max1 = 0;
                cits[i] = 1;
                for (int z = 0; z < n; z++)
                {
                    if (mas[i, z] > max1)
                    {
                        cits[i] = z;
                        max1 = mas[i, z];
                    }
                }
            }

            int[] winmas = new int[111];

            for (int i = 0; i < winmas.Length; i ++ )
            {
                winmas[i] = 0;
            }

            for(int i = 0; i < cits.Length; i++)
            {
                winmas[cits[i]]++;
            }

            int max2 = 0;
            int viner = 0;

            for (int i = 0; i < winmas.Length; ++i)
            {
                if (winmas[i] > max2)
                {
                    viner = i + 1;
                    max2 = winmas[i];
                }
            }

            System.Console.WriteLine(viner);

            return;

        }
    }
}


using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main()
        {
           // string n = Console.ReadLine();

            string foo = Console.ReadLine();
            string[] tokens = foo.Split(' ');
            int[] nm = new int[2];
            int j = 0;
            foreach (var i in tokens)
            {
                nm[j ++] = Convert.ToInt32(i);
            }

            int n = nm[0];
            int m = nm[1];

            int[,] mas = new int[m,n];

            for (int i = 0; i < m; i++)
            {
                foo = Console.ReadLine();
                tokens = foo.Split(' ');

                for (int z = 0; z < n; z++)
                {
                    mas[i, z] = Convert.ToInt32(tokens[z]);
                }
            }

            int[] cits = new int[m];

            for (int i = 0; i < m; i++)
            {
                int max1 = 0;
                cits[i] = 0;
                for (int z = 0; z < n; z++)
                {
                    if (mas[i, z] > max1)
                    {
                        cits[i] = z;
                        max1 = mas[i, z];
                    }
                }
            }

            int[] winmas = new int[111];

            for (int i = 0; i < winmas.Length; i ++ )
            {
                winmas[i] = 0;
            }

            for(int i = 0; i < cits.Length; i++)
            {
                winmas[cits[i]]++;
            }

            int max2 = 0;
            int viner = 0;

            for (int i = 0; i < winmas.Length; ++i)
            {
                if (winmas[i] > max2)
                {
                    viner = i + 1;
                    max2 = winmas[i];
                }
            }

            System.Console.WriteLine(viner);

            return;

        }
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

public class Solver
{
    void Solve()
    {
        int n = ReadInt();
        int m = ReadInt();
        var a = ReadIntMatrix(m);
        var pob1 = new int[m];
        int max = 0;
        for (int i = 0; i < m; i++)
        {

            for (int j = 0; j < n; j++)
            {
                if (a[i][j] > max)
                {
                    max = a[i][j];
                    pob1[i] = j + 1;
                }
            }
            max = 0;

        }

        int ind = 0;
        var count = new int[m];
        int maxcont = 0;
        for (int j = 0; j < m; j++)
            for(int t = j; t < m; t++)
        {
            if (pob1[j] == pob1[t])
            {
                count[j]++;
            }
        }
        for (int j = 0; j < m; j++)
        {
            if (maxcont > count[j])
            {
                maxcont = count[j];
            }
        }

        Write(maxcont+1);
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        //reader = new StreamReader(Console.OpenStandardInput());
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("hull.in");
        //writer = new StreamWriter("hull.out");
#endif
        try
        {
            //            var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
            //            thread.Start();
            //            thread.Join();
            checked
            {
                new Solver().Solve();
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
#if DEBUG
#else
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write
    private static Queue<string> currentLineTokens = new Queue<string>();
    private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); }
    public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue<string>(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }
    public static int ReadInt() { return int.Parse(ReadToken()); }
    public static long ReadLong() { return long.Parse(ReadToken()); }
    public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
    public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }
    public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }
    public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }
    public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;
    }
    public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }
    public static void WriteArray<T>(IEnumerable<T> array) { writer.WriteLine(string.Join(" ", array)); }
    public static void Write(params object[] array) { WriteArray(array); }
    public static void WriteLines<T>(IEnumerable<T> array) { foreach (var a in array)writer.WriteLine(a); }
    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }
    private static T[] Init<T>(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }
    #endregion
}


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApplication2", "ConsoleApplication2\ConsoleApplication2.csproj", "{14C21F90-B0BA-48CF-A470-4E111C32DE70}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{14C21F90-B0BA-48CF-A470-4E111C32DE70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{14C21F90-B0BA-48CF-A470-4E111C32DE70}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{14C21F90-B0BA-48CF-A470-4E111C32DE70}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{14C21F90-B0BA-48CF-A470-4E111C32DE70}.Release|Any CPU.Build.0 = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
EndGlobal


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

public class Solver
{
    void Solve()
    {
        int n = ReadInt();
        int m = ReadInt();
        var a = ReadIntMatrix(m);
        var pob1=new int [m];
        int pob2=0;
        int max = 0;
        int count = 0;
        for (int i = 0; i < m; i++)
        {

            for (int j = 0; j < n; j++)
            {
                if (a[i][j] > max)
                {
                    max = a[i][j];
                    pob1[i] = j + 1;
                }
            }
            max = 0;
        }

        for (int i = 0; i < m; i++)
        {
            for (int j = i; j < m; j++)
            {
                if (pob1[i] == pob1[j])
                    count++;
            }

            if (count > max)
            {
                max = count;
                pob2 = i+1;
            }
            count = 0;
        }

        Write(pob2);
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        //reader = new StreamReader(Console.OpenStandardInput());
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("hull.in");
        //writer = new StreamWriter("hull.out");
#endif
        try
        {
            //            var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
            //            thread.Start();
            //            thread.Join();
            checked
            {
                new Solver().Solve();
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
#if DEBUG
#else
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write
    private static Queue<string> currentLineTokens = new Queue<string>();
    private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); }
    public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue<string>(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }
    public static int ReadInt() { return int.Parse(ReadToken()); }
    public static long ReadLong() { return long.Parse(ReadToken()); }
    public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
    public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }
    public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }
    public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }
    public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;
    }
    public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }
    public static void WriteArray<T>(IEnumerable<T> array) { writer.WriteLine(string.Join(" ", array)); }
    public static void Write(params object[] array) { WriteArray(array); }
    public static void WriteLines<T>(IEnumerable<T> array) { foreach (var a in array)writer.WriteLine(a); }
    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }
    private static T[] Init<T>(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }
    #endregion
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

public class Solver
{
    void Solve()
    {
        int n = ReadInt();
        int m = ReadInt();
        var a = ReadIntMatrix(m);
        var pob1 = new int[m];
        int max = 0;
        for (int i = 0; i < m; i++)
        {

            for (int j = 0; j < n; j++)
            {
                if (a[i][j] > max)
                {
                    max = a[i][j];
                    pob1[i] = j + 1;
                }
            }
            max = 0;

        }

        int ind = 0;
        var count = new int[m];
        int maxcont = 0;
        for (int j = 0; j < m; j++)
            for(int t = j; t < m; t++)
        {
            if (pob1[j] == pob1[t])
            {
                count[j]++;
            }
        }
        int r=0;
        for (int j = 0; j < m; j++)
        {
            if (count[j] > maxcont )
            {

                maxcont = count[j];
                r = j;
            }
        }

        Write(r+1);
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        //reader = new StreamReader(Console.OpenStandardInput());
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("hull.in");
        //writer = new StreamWriter("hull.out");
#endif
        try
        {
            //            var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
            //            thread.Start();
            //            thread.Join();
            checked
            {
                new Solver().Solve();
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
#if DEBUG
#else
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write
    private static Queue<string> currentLineTokens = new Queue<string>();
    private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); }
    public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue<string>(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }
    public static int ReadInt() { return int.Parse(ReadToken()); }
    public static long ReadLong() { return long.Parse(ReadToken()); }
    public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
    public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }
    public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }
    public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }
    public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;
    }
    public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }
    public static void WriteArray<T>(IEnumerable<T> array) { writer.WriteLine(string.Join(" ", array)); }
    public static void Write(params object[] array) { WriteArray(array); }
    public static void WriteLines<T>(IEnumerable<T> array) { foreach (var a in array)writer.WriteLine(a); }
    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }
    private static T[] Init<T>(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }
    #endregion
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

public class Solver
{
    void Solve()
    {
        int n = ReadInt();
        int m = ReadInt();
        var a = ReadIntMatrix(m);
        var win1 = new int[n];
        int id = 0;
        int  max = 0;
      for (int i = 0; i < m; i++)
        {
           max = 0;
            for (int j = 0; j < n; j++)
            {
                if (max < a[i][j])
                {
                    max = a[i][j];
                    id = j;
                }

            }

            win1[id]++;
            id = 0;

        }
      id = 0;
        max = 0;
        for (int i = 0; i < n; i++)
            if (max > win1[i])
            {
                max = win1[i];
                id = i;
            }
          Write(id+1);
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        //reader = new StreamReader(Console.OpenStandardInput());
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("hull.in");
        //writer = new StreamWriter("hull.out");
#endif
        try
        {
            //            var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
            //            thread.Start();
            //            thread.Join();
            checked
            {
                new Solver().Solve();
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
#if DEBUG
#else
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write
    private static Queue<string> currentLineTokens = new Queue<string>();
    private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); }
    public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue<string>(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }
    public static int ReadInt() { return int.Parse(ReadToken()); }
    public static long ReadLong() { return long.Parse(ReadToken()); }
    public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
    public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }
    public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }
    public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }
    public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;
    }
    public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }
    public static void WriteArray<T>(IEnumerable<T> array) { writer.WriteLine(string.Join(" ", array)); }
    public static void Write(params object[] array) { WriteArray(array); }
    public static void WriteLines<T>(IEnumerable<T> array) { foreach (var a in array)writer.WriteLine(a); }
    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }
    private static T[] Init<T>(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }
    #endregion
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

public class Solver
{
    void Solve()
    {
        int n = ReadInt();
        int m = ReadInt();
        var a = ReadIntMatrix(m);
        var pob1=new int [m];
        int pob2=0;
        int max = 0;
        int count = 0;
        for (int i = 0; i < m; i++)
        {

            for (int j = 0; j < n; j++)
            {
                if (a[i][j] > max)
                {
                    max = a[i][j];
                    pob1[i] = j + 1;
                }
            }
            max = 0;
        }

        for (int i = 0; i < m; i++)
        {
            for (int j = i; j < m; j++)
            {
                if (pob1[i] == pob1[j])
                    count++;
            }

            if (count > max)
            {
                max = count;
                pob2 = pob1[i];
            }
            count = 0;
        }

        Write(pob2);
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        //reader = new StreamReader(Console.OpenStandardInput());
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("hull.in");
        //writer = new StreamWriter("hull.out");
#endif
        try
        {
            //            var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
            //            thread.Start();
            //            thread.Join();
            checked
            {
                new Solver().Solve();
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
#if DEBUG
#else
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write
    private static Queue<string> currentLineTokens = new Queue<string>();
    private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); }
    public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue<string>(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }
    public static int ReadInt() { return int.Parse(ReadToken()); }
    public static long ReadLong() { return long.Parse(ReadToken()); }
    public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
    public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }
    public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }
    public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }
    public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;
    }
    public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }
    public static void WriteArray<T>(IEnumerable<T> array) { writer.WriteLine(string.Join(" ", array)); }
    public static void Write(params object[] array) { WriteArray(array); }
    public static void WriteLines<T>(IEnumerable<T> array) { foreach (var a in array)writer.WriteLine(a); }
    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }
    private static T[] Init<T>(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }
    #endregion
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

public class Solver
{
    void Solve()
    {
        int n = ReadInt();
        int m = ReadInt();
        var a = ReadIntMatrix(m);
        var win1 = new int[n];
        int id = 0;
        int  max = 0;
      for (int i = 0; i < m; i++)
        {
           max = 0;
            for (int j = 0; j < n; j++)
            {
                if (max < a[i][j])
                {
                    max = a[i][j];
                    id = j;
                }

            }

            win1[id]++;
            id = 0;

        }
      id = 0;
        max = 0;
        for (int i = 0; i < n; i++)
            if (max < win1[i])
            {
                max = win1[i];
                id = i;
            }
          Write(id+1);
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        //reader = new StreamReader(Console.OpenStandardInput());
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("hull.in");
        //writer = new StreamWriter("hull.out");
#endif
        try
        {
            //            var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
            //            thread.Start();
            //            thread.Join();
            checked
            {
                new Solver().Solve();
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
#if DEBUG
#else
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write
    private static Queue<string> currentLineTokens = new Queue<string>();
    private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); }
    public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue<string>(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }
    public static int ReadInt() { return int.Parse(ReadToken()); }
    public static long ReadLong() { return long.Parse(ReadToken()); }
    public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
    public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }
    public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }
    public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }
    public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;
    }
    public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }
    public static void WriteArray<T>(IEnumerable<T> array) { writer.WriteLine(string.Join(" ", array)); }
    public static void Write(params object[] array) { WriteArray(array); }
    public static void WriteLines<T>(IEnumerable<T> array) { foreach (var a in array)writer.WriteLine(a); }
    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }
    private static T[] Init<T>(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }
    #endregion
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

public class Solver
{
    void Solve()
    {
        int n = ReadInt();
        int m = ReadInt();
        var a = ReadIntMatrix(m);
        var pob1=new int [m];
        int pob2=0;
        int max = 0;
        int count = 0;
        for (int i = 0; i < m; i++)
        {

            for (int j = 0; j < n; j++)
            {
                if (a[i][j] > max)
                {
                    max = a[i][j];
                    pob1[i] = j + 1;
                }
            }
            max = 0;
        }
        int min=0;
        for (int i = 0; i < m; i++)
        {
            for (int j = 0; j < m; j++)
            {
                if (pob1[i] == pob1[j])
                    count++;
                if (pob1[i] < pob1[j])
                    min = pob1[i];
            }

            if (count > max)
            {
                max = count;
                pob2 = pob1[i];
            }
            if (max == 0)
                pob2 = min;
                    count = 0;
        }

        Write(pob2);
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        //reader = new StreamReader(Console.OpenStandardInput());
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("hull.in");
        //writer = new StreamWriter("hull.out");
#endif
        try
        {
            //            var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
            //            thread.Start();
            //            thread.Join();
            checked
            {
                new Solver().Solve();
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
#if DEBUG
#else
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write
    private static Queue<string> currentLineTokens = new Queue<string>();
    private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); }
    public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue<string>(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }
    public static int ReadInt() { return int.Parse(ReadToken()); }
    public static long ReadLong() { return long.Parse(ReadToken()); }
    public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
    public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }
    public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }
    public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }
    public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;
    }
    public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }
    public static void WriteArray<T>(IEnumerable<T> array) { writer.WriteLine(string.Join(" ", array)); }
    public static void Write(params object[] array) { WriteArray(array); }
    public static void WriteLines<T>(IEnumerable<T> array) { foreach (var a in array)writer.WriteLine(a); }
    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }
    private static T[] Init<T>(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }
    #endregion
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

public class Solver
{
    void Solve()
    {
        int n = ReadInt();
        int m = ReadInt();
        var a = ReadIntMatrix(m);
        var pob1=new int [m];
        int pob2=0;
        int max = 0;
        int count = 0;
        for (int i = 0; i < m; i++)
        {

            for (int j = 0; j < n; j++)
            {
                if (a[i][j] > max)
                {
                    max = a[i][j];
                    pob1[i] = j + 1;
                }
            }
            max = 0;
        }
        int min=0;
        for (int i = 0; i < m; i++)
        {
            for (int j = 0; j < m; j++)
            {
                if (pob1[i] == pob1[j])
                    count++;
                if (pob1[i] < pob1[j])
                    min = pob1[i];
            }

            if (count >= max)
            {
                max = count;
                pob2 = pob1[i];
            }
            if (max == 0)
                pob2 = min;
                    count = 0;
        }

        Write(pob2);
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        //reader = new StreamReader(Console.OpenStandardInput());
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("hull.in");
        //writer = new StreamWriter("hull.out");
#endif
        try
        {
            //            var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
            //            thread.Start();
            //            thread.Join();
            checked
            {
                new Solver().Solve();
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
#if DEBUG
#else
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write
    private static Queue<string> currentLineTokens = new Queue<string>();
    private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); }
    public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue<string>(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }
    public static int ReadInt() { return int.Parse(ReadToken()); }
    public static long ReadLong() { return long.Parse(ReadToken()); }
    public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
    public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }
    public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }
    public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }
    public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;
    }
    public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }
    public static void WriteArray<T>(IEnumerable<T> array) { writer.WriteLine(string.Join(" ", array)); }
    public static void Write(params object[] array) { WriteArray(array); }
    public static void WriteLines<T>(IEnumerable<T> array) { foreach (var a in array)writer.WriteLine(a); }
    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }
    private static T[] Init<T>(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }
    #endregion
}


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

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
        // int n = int.Parse(Console.ReadLine());
            string[] s = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]);
            int m = int.Parse(s[1]);
            int[] A = new int[n];
            for(int i=0;i<n;i++)
                A[i]=0;
            for (int j = 0; j < m; j++)
            {
                int max = 0;
                int k=0;
                string[] golos=Console.ReadLine().Split(' ');
                for (int i = 0; i < n; i++)
                {
                    if (int.Parse(golos[i]) > max)
                    {
                        k = i;
                        max = int.Parse(golos[i]);
                    }
                }
                //Console.WriteLine(k+1);
                A[k] = A[k] + 1;
            }
           int  maxx=0;
            int jj = 0;
            for (int i = 0; i < n; i++)
                if (A[i] > maxx)
                {
                    jj = i;
                    maxx = A[i];
                }
            Console.WriteLine(jj+1);
           // Console.ReadKey();
        }
    }
}


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

namespace TaskA
{
    class Program
    {
        static void Main()
        {
            string[] s = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]);
            int m = int.Parse(s[1]);

            int[] votes = new int[n];
            int[] a;
            //int max = 0;
            int indexMax = 0;

            for (int i = 0; i < m; i++)
            {
                a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

                indexMax = 0;
                for (int j = 0; j < n; j++)
                {
                    if (a[j] > a[indexMax])
                    {
                        indexMax = j;
                    }
                }

                votes[indexMax]++;
                //for (int j = 0; j < n; j++)
                //{
                //    if (max < a[j])
                //    {
                //        max = a[j];
                //        indexMax = j;
                //    }
                //    else if (max == a[j] && indexMax > j)
                //    {
                //        indexMax = j;
                //    }
                //}
            }

            indexMax = 0;
            for (int i = 0; i < n; i++)
            {
                if (votes[i] > votes[indexMax])
                {
                    indexMax = i;
                }
            }

            Console.WriteLine(indexMax + 1);
            //Console.Read();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using System.IO;
using System.Numerics;

namespace probleme {
    class Program {
        static void Main(string[] args) {
            string[] s = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]), m = int.Parse(s[1]);
            int[] win = new int[n + 1];
            int max, ans;
            for (int i = 1; i <= m; i++) {
                int[] v = Array.ConvertAll(Console.ReadLine().Split(' '), x => int.Parse(x));
                max = -1;
                ans = 0;
                for (int j = 0; j < n; j++)
                    if (v[j] > max) {
                        max = v[j];
                        ans = j + 1;
                    }
                win[ans]++;
            }
            max = -1;
            ans = 0;
            for (int i = 1; i <= n;i++)
                if (win[i] > max) {
                    max = win[i];
                    ans = i;
                }
            Console.WriteLine(ans);
            //Console.ReadKey();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using System.IO;
using System.Numerics;

namespace probleme {
    class Program {
        static void Main(string[] args) {
            string[] s = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]), m = int.Parse(s[1]);
            int[] win = new int[n + 1];
            int max, ans;
            for (int i = 1; i <= m; i++) {
                int[] v = Array.ConvertAll(Console.ReadLine().Split(' '), s => int.Parse(s));
                max = 0;
                ans = 0;
                for (int j = 0; j < n; j++)
                    if (v[j] > max) {
                        max = v[j];
                        ans = j + 1;
                    }
                win[ans]++;
            }
            max = 0;
            ans = 0;
            for (int i = 1; i <= n;i++)
                if (win[i] > max) {
                    max = win[i];
                    ans = i;
                }
            Console.WriteLine(ans);
            //Console.ReadKey();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using System.IO;
using System.Numerics;

namespace probleme {
    class Program {
        static void Main(string[] args) {
            string[] s = Console.ReadLine().Split(' ');
            int n = int.Parse(s[0]), m = int.Parse(s[1]);
            int[] win = new int[n + 1];
            int max, ans;
            for (int i = 1; i <= m; i++) {
                int[] v = Array.ConvertAll(Console.ReadLine().Split(' '), x => int.Parse(x));
                max = 0;
                ans = 0;
                for (int j = 0; j < n; j++)
                    if (v[j] > max) {
                        max = v[j];
                        ans = j + 1;
                    }
                win[ans]++;
            }
            max = 0;
            ans = 0;
            for (int i = 1; i <= n;i++)
                if (win[i] > max) {
                    max = win[i];
                    ans = i;
                }
            Console.WriteLine(ans);
            //Console.ReadKey();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;

namespace CodeForces.PRACTICE
{
    // Elections (implementation)
    class _570A
    {
        static void Main(string[] args)
        {
            string[] ss = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            int n = int.Parse(ss[0]);
            int m = int.Parse(ss[1]);
            int[] winner = new int[n];
            int max, maxPos;
            for (int j = 0; j < m; j++)
            {
                ss = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                max = -1;
                maxPos = -1;
                for (int i = 0; i < n; i++)
                {
                    int a = int.Parse(ss[i]);
                    if (a > max) { max = a; maxPos = i; }
                }
                winner[maxPos]++;
            }
            max = -1;
            maxPos = -1;
            for (int i = 0; i < n; i++)
            {
                if (winner[i] > max) { max = winner[i]; maxPos = i; }
            }
            Console.WriteLine(maxPos + 1);
        }
    }
}


using System;
using System.IO;

namespace CF316
{
    class Program
    {
        static void Main(string[] args)
        {
            //var sr = new InputReader(new StreamReader(new FileStream("input.txt", FileMode.Open)));
            var sr = new InputReader(Console.In);
            var sw = Console.Out;
            var task = new Task();
            task.Solve(1, sr, sw);
        }
    }

    class Task
    {
        public void Solve(int testNumber, InputReader sr, TextWriter sw)
        {
            var input = sr.NextString().Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries);
            var n = Int32.Parse(input[0]);
            var m = Int32.Parse(input[1]);
            var votes = new int[m + 1];
            for (var i = 0; i < m; i++)
            {
                input = sr.NextString().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                var array = new Tuple<int, long>[n];
                for (var j = 0; j < n; j++)
                {
                    array[j] = new Tuple<int, long>(j + 1, Int64.Parse(input[j]));
                }
                Array.Sort(array, Comparer);
                votes[array[n - 1].Item1]++;
            }
            var maxIndx = 1;
            for (var i = 2; i <= m; i++)
            {
                if (votes[i] > votes[maxIndx])
                {
                    maxIndx = i;
                }
            }
            sw.WriteLine(maxIndx);
        }

        private int Comparer(Tuple<int, long> a, Tuple<int, long> b)
        {
            if (a.Item2 == b.Item2)
            {
                return -a.Item1.CompareTo(b.Item1);
            }
            return a.Item2.CompareTo(b.Item2);
        }
    }

    class InputReader : IDisposable
    {
        private readonly TextReader sr;
        private bool isDispose = false;
        public InputReader(TextReader stream)
        {
            sr = stream;
        }

        public string NextString()
        {
            var result = sr.ReadLine();
            return result;
        }

        public int NextInt32()
        {
            return Int32.Parse(NextString());
        }

        public long NextInt64()
        {
            return Int64.Parse(NextString());
        }
        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        protected void Dispose(bool dispose)
        {
            if (!isDispose)
            {
                if (dispose)
                {
                    sr.Close();
                }
                isDispose = true;
            }
        }

        ~InputReader()
        {
            Dispose(false);
        }
    }
}


using System;
using System.IO;

namespace CF316
{
    class Program
    {
        static void Main(string[] args)
        {
            //var sr = new InputReader(new StreamReader(new FileStream("input.txt", FileMode.Open)));
            var sr = new InputReader(Console.In);
            var sw = Console.Out;
            var task = new Task();
            task.Solve(1, sr, sw);
        }
    }

    class Task
    {
        public void Solve(int testNumber, InputReader sr, TextWriter sw)
        {
            var input = sr.NextString().Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries);
            var n = Int32.Parse(input[0]);
            var m = Int32.Parse(input[1]);
            var votes = new int[n + 1];
            for (var i = 0; i < m; i++)
            {
                input = sr.NextString().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                var array = new Tuple<int, long>[n];
                for (var j = 0; j < n; j++)
                {
                    array[j] = new Tuple<int, long>(j + 1, Int64.Parse(input[j]));
                }
                Array.Sort(array, Comparer);
                votes[array[n - 1].Item1]++;
            }
            var maxIndx = 1;
            for (var i = 2; i <= n; i++)
            {
                if (votes[i] > votes[maxIndx])
                {
                    maxIndx = i;
                }
            }
            sw.WriteLine(maxIndx);
        }

        private int Comparer(Tuple<int, long> a, Tuple<int, long> b)
        {
            if (a.Item2 == b.Item2)
            {
                return -a.Item1.CompareTo(b.Item1);
            }
            return a.Item2.CompareTo(b.Item2);
        }
    }

    class InputReader : IDisposable
    {
        private readonly TextReader sr;
        private bool isDispose = false;
        public InputReader(TextReader stream)
        {
            sr = stream;
        }

        public string NextString()
        {
            var result = sr.ReadLine();
            return result;
        }

        public int NextInt32()
        {
            return Int32.Parse(NextString());
        }

        public long NextInt64()
        {
            return Int64.Parse(NextString());
        }
        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        protected void Dispose(bool dispose)
        {
            if (!isDispose)
            {
                if (dispose)
                {
                    sr.Close();
                }
                isDispose = true;
            }
        }

        ~InputReader()
        {
            Dispose(false);
        }
    }
}


using System;
using System.IO;

namespace Issue_570A
{
    class Program
    {
        public static void Main(string[] args) {
            var candidates_count = IO.Read();
            var cities_count = IO.Read();

            var global_results = new int[candidates_count];

            int global_winner_index = 0;
            int max_wins = 0;

            int local_winner_index = 0;
            int max_votes;
            int current;

            for (int i = 0; i < cities_count; ++i) {
                max_votes = 0;

                for (int j = 0; j < candidates_count; ++j) {
                    current = IO.Read();

                    if (current > max_votes) {
                        max_votes = current;
                        local_winner_index = j;
                    }
                }

                global_results[local_winner_index]++;

                if (global_results[local_winner_index] > max_wins) {
                    max_wins = global_results[local_winner_index];
                    global_winner_index = local_winner_index;
                }
            }

            Console.WriteLine(global_winner_index + 1);
        }
    }

    public static class IO {
        public static bool IsInputError = false;
        public static bool IsEndOfLine = false;

        static IO() {
            Reader = new StreamReader(
                Console.OpenStandardInput(sizeof(int)),
                System.Text.Encoding.ASCII,
                false,
                sizeof(int),
                false);
        }

        public static StreamReader Reader { get; set; }

        public static int Read() {
            const int zeroCode = (int) '0';

            int result = 0;
            int digit;
            int cache1;
            int cache2;

            var isNegative = false;
            var symbol = Reader.Read();
            IsInputError = false;
            IsEndOfLine = false;

            while (symbol == ' ') {
                symbol = Reader.Read();
            }

            if (symbol == '-') {
                isNegative = true;
                symbol = Reader.Read();
            }

            for ( ;
                (symbol != -1) && (symbol != ' ');
                symbol = Reader.Read()
            ) {
                digit = symbol - zeroCode;

                // if symbol == \n
                if (symbol == 13) {
                    // skip next \r symbol
                    Reader.Read();
                    IsEndOfLine = true;
                    break;
                }

                if (digit < 10 && digit >= 0) {
                    cache1 = result << 1;
                    cache2 = cache1 << 2;
                    result = cache1 + cache2 + digit;
                } else {
                    IsInputError = true;
                    break;
                }
            }

            return isNegative ? ~result + 1 : result;
        }
    }
}


using System;
using System.IO;

namespace Issue_570A
{
    class Program
    {
        public static void Main(string[] args) {
            var candidates_count = IO.Read();
            var cities_count = IO.Read();

            var global_results = new int[candidates_count];

            int global_winner_index = candidates_count;
            int max_wins = 0;

            int local_winner_index = 0;
            int max_votes;
            int current;

            for (int i = 0; i < cities_count; ++i) {
                max_votes = 0;

                for (int j = 0; j < candidates_count; ++j) {
                    current = IO.Read();

                    if (current > max_votes) {
                        max_votes = current;
                        local_winner_index = j;
                    }
                }

                global_results[local_winner_index]++;

                if (global_results[local_winner_index] >= max_wins
                    && local_winner_index < global_winner_index)
                {
                    max_wins = global_results[local_winner_index];
                    global_winner_index = local_winner_index;
                }
            }

            Console.WriteLine(global_winner_index + 1);
        }
    }

    public static class IO {
        public static bool IsInputError = false;
        public static bool IsEndOfLine = false;

        static IO() {
            Reader = new StreamReader(
                Console.OpenStandardInput(sizeof(int)),
                System.Text.Encoding.ASCII,
                false,
                sizeof(int),
                false);
        }

        public static StreamReader Reader { get; set; }

        public static int Read() {
            const int zeroCode = (int) '0';

            int result = 0;
            int digit;
            int cache1;
            int cache2;

            var isNegative = false;
            var symbol = Reader.Read();
            IsInputError = false;
            IsEndOfLine = false;

            while (symbol == ' ') {
                symbol = Reader.Read();
            }

            if (symbol == '-') {
                isNegative = true;
                symbol = Reader.Read();
            }

            for ( ;
                (symbol != -1) && (symbol != ' ');
                symbol = Reader.Read()
            ) {
                digit = symbol - zeroCode;

                // if symbol == \n
                if (symbol == 13) {
                    // skip next \r symbol
                    Reader.Read();
                    IsEndOfLine = true;
                    break;
                }

                if (digit < 10 && digit >= 0) {
                    cache1 = result << 1;
                    cache2 = cache1 << 2;
                    result = cache1 + cache2 + digit;
                } else {
                    IsInputError = true;
                    break;
                }
            }

            return isNegative ? ~result + 1 : result;
        }
    }
}


using System;
using System.IO;

namespace Issue_570A
{
    class Program
    {
        public static void Main(string[] args) {
            var candidates_count = IO.Read();
            var cities_count = IO.Read();

            var results = new int[candidates_count];

            int max_wins = 0;

            int local_winner = 0;
            int max_votes;
            int current;

            for (int i = 0; i < cities_count; ++i) {
                max_votes = 0;

                for (int j = 0; j < candidates_count; ++j) {
                    current = IO.Read();

                    if (current > max_votes) {
                        max_votes = current;
                        local_winner = j;
                    }
                }

                results[local_winner]++;
            }

            int global_winner = 0;

            for (int i = 1; i < candidates_count; ++i) {
                if (results[i] > results[global_winner]) {
                    global_winner = i;
                }
            }

            Console.WriteLine(global_winner + 1);
        }
    }

    public static class IO {
        public static bool IsInputError = false;
        public static bool IsEndOfLine = false;

        static IO() {
            Reader = new StreamReader(
                Console.OpenStandardInput(sizeof(int)),
                System.Text.Encoding.ASCII,
                false,
                sizeof(int),
                false);
        }

        public static StreamReader Reader { get; set; }

        public static int Read() {
            const int zeroCode = (int) '0';

            int result = 0;
            int digit;
            int cache1;
            int cache2;

            var isNegative = false;
            var symbol = Reader.Read();
            IsInputError = false;
            IsEndOfLine = false;

            while (symbol == ' ') {
                symbol = Reader.Read();
            }

            if (symbol == '-') {
                isNegative = true;
                symbol = Reader.Read();
            }

            for ( ;
                (symbol != -1) && (symbol != ' ');
                symbol = Reader.Read()
            ) {
                digit = symbol - zeroCode;

                // if symbol == \n
                if (symbol == 13) {
                    // skip next \r symbol
                    Reader.Read();
                    IsEndOfLine = true;
                    break;
                }

                if (digit < 10 && digit >= 0) {
                    cache1 = result << 1;
                    cache2 = cache1 << 2;
                    result = cache1 + cache2 + digit;
                } else {
                    IsInputError = true;
                    break;
                }
            }

            return isNegative ? ~result + 1 : result;
        }
    }
}


using System;
using System.IO;

namespace Issue_570A
{
    class Program
    {
        public static void Main(string[] args) {
            var candidates_count = IO.Read();
            var cities_count = IO.Read();

            var global_results = new int[candidates_count];

            int global_winner_index = 0;
            int max_wins = 0;

            int local_winner_index = 0;
            int max_votes;
            int current;

            for (int i = 0; i < cities_count; ++i) {
                max_votes = 0;

                for (int j = 0; j < candidates_count; ++j) {
                    current = IO.Read();

                    if (current > max_votes) {
                        max_votes = current;
                        local_winner_index = j;
                    }
                }

                global_results[local_winner_index]++;

                if (global_results[local_winner_index] >= max_wins
                    && local_winner_index < global_winner_index)
                {
                    max_wins = global_results[local_winner_index];
                    global_winner_index = local_winner_index;
                }
            }

            Console.WriteLine(global_winner_index + 1);
        }
    }

    public static class IO {
        public static bool IsInputError = false;
        public static bool IsEndOfLine = false;

        static IO() {
            Reader = new StreamReader(
                Console.OpenStandardInput(sizeof(int)),
                System.Text.Encoding.ASCII,
                false,
                sizeof(int),
                false);
        }

        public static StreamReader Reader { get; set; }

        public static int Read() {
            const int zeroCode = (int) '0';

            int result = 0;
            int digit;
            int cache1;
            int cache2;

            var isNegative = false;
            var symbol = Reader.Read();
            IsInputError = false;
            IsEndOfLine = false;

            while (symbol == ' ') {
                symbol = Reader.Read();
            }

            if (symbol == '-') {
                isNegative = true;
                symbol = Reader.Read();
            }

            for ( ;
                (symbol != -1) && (symbol != ' ');
                symbol = Reader.Read()
            ) {
                digit = symbol - zeroCode;

                // if symbol == \n
                if (symbol == 13) {
                    // skip next \r symbol
                    Reader.Read();
                    IsEndOfLine = true;
                    break;
                }

                if (digit < 10 && digit >= 0) {
                    cache1 = result << 1;
                    cache2 = cache1 << 2;
                    result = cache1 + cache2 + digit;
                } else {
                    IsInputError = true;
                    break;
                }
            }

            return isNegative ? ~result + 1 : result;
        }
    }
}


using System;
using System.IO;

namespace Issue_570A
{
    class Program
    {
        public static void Main(string[] args) {
            var candidates_count = IO.Read();
            var cities_count = IO.Read();

            var results = new int[candidates_count];

            int max_wins = 0;

            int local_winner = 0;
            int max_votes;
            int current;

            for (int i = 0; i < cities_count; ++i) {
                max_votes = -1;

                for (int j = 0; j < candidates_count; ++j) {
                    current = IO.Read();

                    if (current > max_votes) {
                        max_votes = current;
                        local_winner = j;
                    }
                }

                results[local_winner]++;
            }

            int global_winner = 0;

            for (int i = 1; i < candidates_count; ++i) {
                if (results[i] > results[global_winner]) {
                    global_winner = i;
                }
            }

            Console.WriteLine(global_winner + 1);
        }
    }

    public static class IO {
        public static bool IsInputError = false;
        public static bool IsEndOfLine = false;

        static IO() {
            Reader = new StreamReader(
                Console.OpenStandardInput(sizeof(int)),
                System.Text.Encoding.ASCII,
                false,
                sizeof(int),
                false);
        }

        public static StreamReader Reader { get; set; }

        public static int Read() {
            const int zeroCode = (int) '0';

            int result = 0;
            int digit;
            int cache1;
            int cache2;

            var isNegative = false;
            var symbol = Reader.Read();
            IsInputError = false;
            IsEndOfLine = false;

            while (symbol == ' ') {
                symbol = Reader.Read();
            }

            if (symbol == '-') {
                isNegative = true;
                symbol = Reader.Read();
            }

            for ( ;
                (symbol != -1) && (symbol != ' ');
                symbol = Reader.Read()
            ) {
                digit = symbol - zeroCode;

                // if symbol == \n
                if (symbol == 13) {
                    // skip next \r symbol
                    Reader.Read();
                    IsEndOfLine = true;
                    break;
                }

                if (digit < 10 && digit >= 0) {
                    cache1 = result << 1;
                    cache2 = cache1 << 2;
                    result = cache1 + cache2 + digit;
                } else {
                    IsInputError = true;
                    break;
                }
            }

            return isNegative ? ~result + 1 : result;
        }
    }
}


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

namespace zadacha2
{
    class Program
    {
        static void Main()
        {
            byte n, m, k = 0, temp = 0, answer = 0;
            int max = -1;
            string[] Data = Console.ReadLine().Split(' ');
            n = Convert.ToByte(Data[0]);
            m = Convert.ToByte(Data[1]);
            int[,] election = new int[m, n];
            byte[] count = new byte[n + 1];

            for (byte i = 0; i < m; i++)
            {
                string[] Data1 = Console.ReadLine().Split(' ');
                for (byte j = 0; j < n; j++)
                {
                    election[i, j] = Convert.ToInt32(Data1[j]);
                    count[j + 1] = 0;
                }

            }

            for (byte i = 0; i < m; i++)
            {
                for (byte j = 0; j < n; j++)
                {
                    if (election[i, j] > max)
                    {
                        if (max != 0 && election[i, j] != 0)
                        {
                            max = election[i, j];
                            temp = j;
                        }
                    }
                }
                count[temp + 1]++;
                max = 0;
            }

            for (byte i = 1; i <= n; i++)
            {
                if (count[i] > max)
                {
                    answer = i;
                    max = count[i];
                }
            }
            Console.WriteLine(answer);
        }
    }
}