#include <bits/stdc++.h>
#define N 100005
#define task "t"
#define mu(x) x*x

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using piii=pair<int,pii>;
const int inf=1e9+7;

int n,m,mark[N],col[N],dem[N];
vector<int> ke[N];

void dfs(int u)
{
    mark[u]=1;
    for (int v:ke[u])
        if (!mark[v]) dfs(v);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie();cout.tie();
    #ifndef ONLINE_JUDGE
    freopen(task".inp","r",stdin);
    freopen(task".out","w",stdout);
    #endif // ONLINE_JUDGE
    cin>>n>>m;
    for (int i=1;i<=m;i++) {
        int u,v;
        cin>>u>>v;
        ke[u].push_back(v);
        ke[v].push_back(u);
    }
    dfs(1);
    for (int i=1;i<=n;i++)
    if (!mark[i]) {
        cout<<-1;
        return 0;
    }
    for (int i=1;i<=n;i++) mark[i]=0;
    int cnt=1;
    for (int u=1;u<=n;u++)
        if (mark[u]!=cnt) {
            col[u]=1;
            for (int v:ke[u]) mark[v]=cnt;
        }
    cnt++;
    for (int u=1;u<=n;u++)
        if (mark[u]==1 && !col[u]) {
            col[u]=2;
            for (int v:ke[u]) mark[v]=cnt;
        }
    cnt++;
    //for (int i=1;i<=n;i++) cout<<col[i]<<" ";
     for (int u=1;u<=n;u++)
        if ((mark[u]==2)  && !col[u]) {
            col[u]=3;
            for (int v:ke[u]) {
                mark[v]=cnt;
            }
        }
    for (int u=1;u<=n;u++)
        for (int v:ke[u])
    if (col[u]==col[v]) {
        cout<<-1;
        return 0;
    }
    for (int i=1;i<=n;i++)
    if (!col[i]) {
        cout<<-1;
        return 0;
    }
    else dem[col[i]]++;
    if (!dem[1] || !dem[2] || !dem[3]) {
        cout<<-1;
        return 0;
    }
    for (int i=1;i<=n;i++) cout<<col[i]<<" ";
    return 0;
}


#include <bits/stdc++.h>
#define N 100005
#define task "t"
#define mu(x) x*x

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using piii=pair<int,pii>;
const int inf=1e9+7;

int n,m,mark[N],col[N];
vector<int> ke[N];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie();cout.tie();
    #ifndef ONLINE_JUDGE
    freopen(task".inp","r",stdin);
    freopen(task".out","w",stdout);
    #endif // ONLINE_JUDGE
    cin>>n>>m;
    for (int i=1;i<=m;i++) {
        int u,v;
        cin>>u>>v;
        ke[u].push_back(v);
        ke[v].push_back(u);
    }
    int cnt=1;
    for (int u=1;u<=n;u++)
        if (mark[u]!=cnt) {
            col[u]=1;
            for (int v:ke[u]) mark[v]=cnt;
        }
    cnt++;
    for (int u=1;u<=n;u++)
        if (mark[u]!=cnt && !col[u]) {
            col[u]=2;
            for (int v:ke[u]) mark[v]=cnt;
        }
    cnt++;
    //for (int i=1;i<=n;i++) cout<<col[i]<<" ";
     for (int u=1;u<=n;u++)
        if (mark[u]!=cnt && !col[u]) {
            col[u]=3;
            for (int v:ke[u]) mark[v]=cnt;
        }
    for (int i=1;i<=n;i++)
    if (!col[i]) {
        cout<<-1;
        return 0;
    }
    for (int i=1;i<=n;i++) cout<<col[i]<<" ";
    return 0;
}


#include <bits/stdc++.h>
#define N 100005
#define task "t"
#define mu(x) x*x

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using piii=pair<int,pii>;
const int inf=1e9+7;

int n,m,mark[N],col[N],dem[N];
vector<int> ke[N];

void dfs(int u)
{
    mark[u]=1;
    for (int v:ke[u])
        if (!mark[v]) dfs(v);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie();cout.tie();
    #ifndef ONLINE_JUDGE
    freopen(task".inp","r",stdin);
    freopen(task".out","w",stdout);
    #endif // ONLINE_JUDGE
    cin>>n>>m;
    for (int i=1;i<=m;i++) {
        int u,v;
        cin>>u>>v;
        ke[u].push_back(v);
        ke[v].push_back(u);
    }
    dfs(1);
    for (int i=1;i<=n;i++)
    if (!mark[i]) {
        cout<<-1;
        return 0;
    }
    for (int i=1;i<=n;i++) mark[i]=0;
    int cnt=1;
    for (int u=1;u<=n;u++)
        if (mark[u]!=cnt) {
            col[u]=1;
            for (int v:ke[u]) mark[v]=cnt;
        }
    cnt++;
    for (int u=1;u<=n;u++)
        if (mark[u]==1 && !col[u]) {
            col[u]=2;
            for (int v:ke[u]) mark[v]=cnt;
        }
    cnt++;
    //for (int i=1;i<=n;i++) cout<<col[i]<<" ";
     for (int u=1;u<=n;u++)
        if ((mark[u]==2)  && !col[u]) {
            col[u]=3;
            for (int v:ke[u]) {
                mark[v]=cnt;
            }
        }
    for (int i=1;i<=n;i++)
    if (!col[i]) {
        cout<<-1;
        return 0;
    }
    else dem[col[i]]++;
     for (int u=1;u<=n;u++)
    for (int v:ke[u])
        if (col[u]==col[v]) {
            cout<<-1;
            return 0;
        }
        else {
            if (ke[u].size()!=n-dem[col[u]]) {
                cout<<-1;
                return 0;
            }
        }
    for (int i=1;i<=n;i++) cout<<col[i]<<" ";
    return 0;
}


#include <bits/stdc++.h>
#define N 100005
#define task "t"
#define mu(x) x*x

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using piii=pair<int,pii>;
const int inf=1e9+7;

int n,m,mark[N],col[N],dem[N];
vector<int> ke[N];

void dfs(int u)
{
    mark[u]=1;
    for (int v:ke[u])
        if (!mark[v]) dfs(v);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie();cout.tie();
    #ifndef ONLINE_JUDGE
    freopen(task".inp","r",stdin);
    freopen(task".out","w",stdout);
    #endif // ONLINE_JUDGE
    cin>>n>>m;
    for (int i=1;i<=m;i++) {
        int u,v;
        cin>>u>>v;
        ke[u].push_back(v);
        ke[v].push_back(u);
    }
    dfs(1);
    for (int i=1;i<=n;i++)
    if (!mark[i]) {
        cout<<-1;
        return 0;
    }
    for (int i=1;i<=n;i++) mark[i]=0;
    int cnt=1;
    for (int u=1;u<=n;u++)
        if (mark[u]!=cnt) {
            col[u]=1;
            for (int v:ke[u]) mark[v]=cnt;
        }
    cnt++;
    for (int u=1;u<=n;u++)
        if (mark[u]!=cnt && !col[u]) {
            col[u]=2;
            for (int v:ke[u]) mark[v]=cnt;
        }
    cnt++;
    //for (int i=1;i<=n;i++) cout<<col[i]<<" ";
     for (int u=1;u<=n;u++)
        if (mark[u]!=cnt && !col[u]) {
            col[u]=3;
            for (int v:ke[u]) mark[v]=cnt;

    }
    for (int i=1;i<=n;i++)
    if (!col[i]) {
        cout<<-1;
        return 0;
    }
    else dem[col[i]]++;
    if (!dem[col[1]] || !dem[col[2]] || !dem[col[3]) {
        cout<<-1;
        return 0;
    }
    for (int i=1;i<=n;i++) cout<<col[i]<<" ";
    return 0;
}


#include <bits/stdc++.h>
#define N 100005
#define task "t"
#define mu(x) x*x

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using piii=pair<int,pii>;
const int inf=1e9+7;

int n,m,mark[N],col[N],dem[N];
vector<int> ke[N];

void dfs(int u)
{
    mark[u]=1;
    for (int v:ke[u])
        if (!mark[v]) dfs(v);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie();cout.tie();
    #ifndef ONLINE_JUDGE
    freopen(task".inp","r",stdin);
    freopen(task".out","w",stdout);
    #endif // ONLINE_JUDGE
    cin>>n>>m;
    for (int i=1;i<=m;i++) {
        int u,v;
        cin>>u>>v;
        ke[u].push_back(v);
        ke[v].push_back(u);
    }
    dfs(1);
    for (int i=1;i<=n;i++)
    if (!mark[i]) {
        cout<<-1;
        return 0;
    }
    for (int i=1;i<=n;i++) mark[i]=0;
    int cnt=1;
    for (int u=1;u<=n;u++)
        if (mark[u]!=cnt) {
            col[u]=1;
            for (int v:ke[u]) mark[v]=cnt;
        }
    cnt++;
    for (int u=1;u<=n;u++)
        if (mark[u]!=cnt && !col[u]) {
            col[u]=2;
            for (int v:ke[u]) mark[v]=cnt;
        }
    cnt++;
    //for (int i=1;i<=n;i++) cout<<col[i]<<" ";
     for (int u=1;u<=n;u++)
        if (mark[u]!=cnt && !col[u]) {
            col[u]=3;
            for (int v:ke[u]) mark[v]=cnt;

    }
    for (int i=1;i<=n;i++)
    if (!col[i]) {
        cout<<-1;
        return 0;
    }
    else dem[col[i]]++;
    if (!dem[1] || !dem[2] || !dem[3]) {
        cout<<-1;
        return 0;
    }
    for (int i=1;i<=n;i++) cout<<col[i]<<" ";
    return 0;
}


#include <bits/stdc++.h>
#define N 100005
#define task "t"
#define mu(x) x*x

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using piii=pair<int,pii>;
const int inf=1e9+7;

int n,m,mark[N],col[N],dem[N];
vector<int> ke[N];

void dfs(int u)
{
    mark[u]=1;
    for (int v:ke[u])
        if (!mark[v]) dfs(v);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie();cout.tie();
    #ifndef ONLINE_JUDGE
    freopen(task".inp","r",stdin);
    freopen(task".out","w",stdout);
    #endif // ONLINE_JUDGE
    cin>>n>>m;
    for (int i=1;i<=m;i++) {
        int u,v;
        cin>>u>>v;
        ke[u].push_back(v);
        ke[v].push_back(u);
    }
    dfs(1);
    for (int i=1;i<=n;i++)
    if (!mark[i]) {
        cout<<-1;
        return 0;
    }
    for (int i=1;i<=n;i++) mark[i]=0;
    int cnt=1;
    for (int u=1;u<=n;u++)
        if (mark[u]!=cnt) {
            col[u]=1;
            for (int v:ke[u]) mark[v]=cnt;
        }
    cnt++;
    for (int u=1;u<=n;u++)
        if (mark[u]!=cnt && !col[u]) {
            col[u]=2;
            for (int v:ke[u]) mark[v]=cnt;
        }
    cnt++;
    //for (int i=1;i<=n;i++) cout<<col[i]<<" ";
     for (int u=1;u<=n;u++)
        if (mark[u]!=cnt && !col[u]) {
            col[u]=3;
            for (int v:ke[u]) mark[v]=cnt;

    }
    for (int i=1;i<=n;i++)
    if (!col[i]) {
        cout<<-1;
        return 0;
    }
    else dem[col[i]]++;
    if (!dem[col[1]] || !dem[col[2]] || !dem[col[3]]) {
        cout<<-1;
        return 0;
    }
    for (int i=1;i<=n;i++) cout<<col[i]<<" ";
    return 0;
}


#include <bits/stdc++.h>
#define N 100005
#define task "t"
#define mu(x) x*x

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using piii=pair<int,pii>;
const int inf=1e9+7;

int n,m,mark[N],col[N],dem[N];
vector<int> ke[N];

void dfs(int u)
{
    mark[u]=1;
    for (int v:ke[u])
        if (!mark[v]) dfs(v);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie();cout.tie();
    #ifndef ONLINE_JUDGE
    freopen(task".inp","r",stdin);
    freopen(task".out","w",stdout);
    #endif // ONLINE_JUDGE
    cin>>n>>m;
    for (int i=1;i<=m;i++) {
        int u,v;
        cin>>u>>v;
        ke[u].push_back(v);
        ke[v].push_back(u);
    }
    dfs(1);
    for (int i=1;i<=n;i++)
    if (!mark[i]) {
        cout<<-1;
        return 0;
    }
    for (int i=1;i<=n;i++) mark[i]=0;
    int cnt=1;
    for (int u=1;u<=n;u++)
        if (mark[u]!=cnt) {
            col[u]=1;
            for (int v:ke[u]) mark[v]=cnt;
        }
    cnt++;
    for (int u=1;u<=n;u++)
        if (mark[u]!=cnt && !col[u]) {
            col[u]=2;
            for (int v:ke[u]) mark[v]=cnt;
        }
    cnt++;
    //for (int i=1;i<=n;i++) cout<<col[i]<<" ";
     for (int u=1;u<=n;u++)
        if (mark[u]!=cnt && !col[u]) {
            col[u]=3;
            for (int v:ke[u]) mark[v]=cnt;

    }
    for (int i=1;i<=n;i++)
    if (!col[i]) {
        cout<<-1;
        return 0;
    }
    else dem[col[i]]++;
    if (!col[1] || !col[2] || !col[3]) {
        cout<<-1;
        return 0;
    }
    for (int i=1;i<=n;i++) cout<<col[i]<<" ";
    return 0;
}


#include <bits/stdc++.h>
#define N 100005
#define task "t"
#define mu(x) x*x

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using piii=pair<int,pii>;
const int inf=1e9+7;

int n,m,mark[N],col[N],dem[N];
vector<int> ke[N];

void dfs(int u)
{
    mark[u]=1;
    for (int v:ke[u])
        if (!mark[v]) dfs(v);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie();cout.tie();
    #ifndef ONLINE_JUDGE
    freopen(task".inp","r",stdin);
    freopen(task".out","w",stdout);
    #endif // ONLINE_JUDGE
    cin>>n>>m;
    for (int i=1;i<=m;i++) {
        int u,v;
        cin>>u>>v;
        ke[u].push_back(v);
        ke[v].push_back(u);
    }
    dfs(1);
    for (int i=1;i<=n;i++)
    if (!mark[i]) {
        cout<<-1;
        return 0;
    }
    for (int i=1;i<=n;i++) mark[i]=0;
    int cnt=1;
    for (int u=1;u<=n;u++)
        if (mark[u]!=cnt) {
            col[u]=1;
            for (int v:ke[u]) mark[v]=cnt;
        }
    cnt++;
    for (int u=1;u<=n;u++)
        if (mark[u]==1 && !col[u]) {
            col[u]=2;
            for (int v:ke[u]) mark[v]=cnt;
        }
    cnt++;
    //for (int i=1;i<=n;i++) cout<<col[i]<<" ";
     for (int u=1;u<=n;u++)
        if ((mark[u]==2)  && !col[u]) {
            col[u]=3;
            for (int v:ke[u]) mark[v]=cnt;

    }
    for (int i=1;i<=n;i++)
    if (!col[i]) {
        cout<<-1;
        return 0;
    }
    else dem[col[i]]++;
    if (!dem[1] || !dem[2] || !dem[3]) {
        cout<<-1;
        return 0;
    }
    for (int i=1;i<=n;i++) cout<<col[i]<<" ";
    return 0;
}


#include <bits/stdc++.h>
#define N 100005
#define task "t"
#define mu(x) x*x

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using piii=pair<int,pii>;
const int inf=1e9+7;

int n,m,mark[N],col[N],dem[N];
vector<int> ke[N];

void dfs(int u)
{
    mark[u]=1;
    for (int v:ke[u])
        if (!mark[v]) dfs(v);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie();cout.tie();
    #ifndef ONLINE_JUDGE
    freopen(task".inp","r",stdin);
    freopen(task".out","w",stdout);
    #endif // ONLINE_JUDGE
    cin>>n>>m;
    for (int i=1;i<=m;i++) {
        int u,v;
        cin>>u>>v;
        ke[u].push_back(v);
        ke[v].push_back(u);
    }
    dfs(1);
    for (int i=1;i<=n;i++)
    if (!mark[i]) {
        cout<<-1;
        return 0;
    }
    for (int i=1;i<=n;i++) mark[i]=0;
    int cnt=1;
    for (int u=1;u<=n;u++)
        if (mark[u]!=cnt) {
            col[u]=1;
            for (int v:ke[u]) mark[v]=cnt;
        }
    cnt++;
    for (int u=1;u<=n;u++)
        if (mark[u]==1 && !col[u]) {
            col[u]=2;
            for (int v:ke[u]) mark[v]=cnt;
        }
    cnt++;
    //for (int i=1;i<=n;i++) cout<<col[i]<<" ";
     for (int u=1;u<=n;u++)
        if ((mark[u]==2)  && !col[u]) {
            col[u]=3;
            for (int v:ke[u]) {
                if (col[v]==3) {
                    cout<<-1;
                    return 0;
                }
                mark[v]=cnt;
            }

    }
    for (int i=1;i<=n;i++)
    if (!col[i]) {
        cout<<-1;
        return 0;
    }
    else dem[col[i]]++;
    if (!dem[1] || !dem[2] || !dem[3]) {
        cout<<-1;
        return 0;
    }
    for (int i=1;i<=n;i++) cout<<col[i]<<" ";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
// #define maxn 500001
// vector< vector<int> >adj(maxn);
int main()
{
	int n,m;
	cin>>n>>m;
	unordered_map<int,int>adjmp[n+1];
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		adjmp[x][y]=1;
		adjmp[y][x]=1;
		// adj[x].push_back(y);
		// adj[y].push_back(x);
	}
// 	for(int i=1;i<=n;i++){
// 	    for(auto j:adjmp[i]){
// 	        cout<<j.first<<" ";
// 	    }cout<<endl;
// 	}
    if(m<n-1){
        cout<<"-1"<<endl;
        return 0;
    }
	unordered_map<int,int>collected;
	int count=1;
	for(int i=1;i<=n;i++){
		if(collected[i]==0){
			collected[i]=count;
			for(int j=1;j<=n;j++){
				if(adjmp[i].count(j)==0 && collected[j]==0){
					collected[j]=count;
				}
			}
			count++;
		}
	}
	int countv=0;
	bool flag1=false,flag2=false,flag3=false,flag4=false;
	for(auto i:collected){
		countv++;
		if(i.second==1){
		    flag1 = true;
		}
		if(i.second == 2)
		flag2=true;
		if(i.second==3)
		flag3=true;
		if(i.second>3)
		flag4=true;
	}
	if(countv<n || !flag1 || !flag2 || !flag3 || flag4){
	    cout<<"-1"<<endl;
	    return 0;
	}
	else{
	    for(int i=1;i<=n;i++){
	        cout<<collected[i]<<" ";
	    }
	    cout<<endl;
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
// #define maxn 500001
// vector< vector<int> >adj(maxn);
#define int long long int
int32_t main()
{
	int n,m;
	cin>>n>>m;
	unordered_map<int,int>adjmp[n+1];
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		adjmp[x][y]=1;
		adjmp[y][x]=1;
		// adj[x].push_back(y);
		// adj[y].push_back(x);
	}
// 	for(int i=1;i<=n;i++){
// 	    for(auto j:adjmp[i]){
// 	        cout<<j.first<<" ";
// 	    }cout<<endl;
// 	}
    if(m<n-1){
        cout<<"-1"<<endl;
        return 0;
    }
	unordered_map<int,int>collected;
	int count=1;
	for(int i=1;i<=n;i++){
		if(collected[i]==0){
			collected[i]=count;
			for(int j=1;j<=n;j++){
				if(adjmp[i].count(j)==0 && collected[j]==0){
					collected[j]=count;
				}
			}
			count++;
		}
	}
	int countv=0;
	bool flag1=false,flag2=false,flag3=false,flag4=false;
	int count1=0,count2=0,count3=0;
	for(auto i:collected){
		countv++;
		if(i.second==1){
		    flag1 = true;
		    count1++;
		}
		if(i.second == 2){
		flag2=true;
		count2++;
		}
		if(i.second==3){
		flag3=true;
		count3++;
		}
		if(i.second>3)
		flag4=true;
	}
	if(countv<n || !flag1 || !flag2 || !flag3 || flag4){
	    cout<<"-1"<<endl;
	    return 0;
	}
	if( m != count1*count2 + count2*count3 + count1*count3){
	    cout<<"-1"<<endl;
	    return 0;
	}

	    for(int i=1;i<=n;i++){
	        cout<<collected[i]<<" ";
	    }
	    cout<<endl;

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main()
{
	int n,m;
	cin>>n>>m;
	unordered_map<int,int>adjmp[n+1];
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		adjmp[x][x]=1;
		adjmp[x][y]=1;
		adjmp[y][x]=1;
		adjmp[y][y]=1;
	}
    if(m<n-1){
        cout<<"-1"<<endl;
        return 0;
    }
	unordered_map<int,int>collected;
	int count=1;
	for(int i=1;i<=n;i++){
		if(collected[i]==0){
			collected[i]=count;
			for(int j=1;j<=n;j++){
				if(adjmp[i].count(j) == 0 && collected[j] == 0){
					collected[j]=count;
				}
			}
			count++;
		}
	}
	int countv=0;
	bool flag1=false,flag2=false,flag3=false,flag4=false;
	int count1=0,count2=0,count3=0;
	for(auto i:collected){
		countv++;
		if(i.second==1){
		    flag1 = true;
		    count1++;
		}
		if(i.second == 2){
		flag2=true;
		count2++;
		}
		if(i.second==3){
		flag3=true;
		count3++;
		}
		if(i.second>3)
		flag4=true;
	}
	if(countv<n || !flag1 || !flag2 || !flag3 || flag4){
	    cout<<"-1"<<endl;
	    return 0;
	}
	if( m != count1*count2 + count2*count3 + count1*count3){
	    cout<<"-1"<<endl;
	    return 0;
	}

	    for(int i=1;i<=n;i++){
	        cout<<collected[i]<<" ";
	    }
	    cout<<endl;

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
// #define maxn 500001
// vector< vector<int> >adj(maxn);
int main()
{
	int n,m;
	cin>>n>>m;
	unordered_map<int,int>adjmp[n+1];
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		adjmp[x][y]=1;
		adjmp[y][x]=1;
		// adj[x].push_back(y);
		// adj[y].push_back(x);
	}
// 	for(int i=1;i<=n;i++){
// 	    for(auto j:adjmp[i]){
// 	        cout<<j.first<<" ";
// 	    }cout<<endl;
// 	}
	unordered_map<int,int>collected;
	int count=0;
	for(int i=1;i<=n;i++){
		if(collected[i]==0){
			collected[i]=count;
			for(int j=1;j<=n;j++){
				if(adjmp[i].count(j)==0 && collected[j]==0){
					collected[j]=count;
				}
			}
			count++;
		}
	}
	int countv=0;
	bool flag=false;
	for(auto i:collected){
		countv++;
		if(i.second>2){
		    flag = true;
		}
	}
	if(countv<n || flag){
	    cout<<"-1"<<endl;
	    return 0;
	}
	else{
	    for(int i=1;i<=n;i++){
	        cout<<collected[i]+1<<" ";
	    }
	    cout<<endl;
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
// #define maxn 500001
// vector< vector<int> >adj(maxn);
int main()
{
	int n,m;
	cin>>n>>m;
	unordered_map<int,int>adjmp[n+1];
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		adjmp[x][y]=1;
		adjmp[y][x]=1;
		// adj[x].push_back(y);
		// adj[y].push_back(x);
	}
// 	for(int i=1;i<=n;i++){
// 	    for(auto j:adjmp[i]){
// 	        cout<<j.first<<" ";
// 	    }cout<<endl;
// 	}
    if(m<n-1){
        cout<<"-1"<<endl;
        return 0;
    }
	unordered_map<int,int>collected;
	int count=0;
	for(int i=1;i<=n;i++){
		if(collected[i]==0){
			collected[i]=count;
			for(int j=1;j<=n;j++){
				if(adjmp[i].count(j)==0 && collected[j]==0){
					collected[j]=count;
				}
			}
			count++;
		}
	}
	int countv=0;
	bool flag=false;
	for(auto i:collected){
		countv++;
		if(i.second>2){
		    flag = true;
		}
	}
	if(countv<n || flag){
	    cout<<"-1"<<endl;
	    return 0;
	}
	else{
	    for(int i=1;i<=n;i++){
	        cout<<collected[i]+1<<" ";
	    }
	    cout<<endl;
	}

	return 0;
}


/* sidchelseafan */
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define INF (ll)1e12
#define sz(a) (int)a.size()
#define pii pair<int,int>
#define pll pair<ll,ll>

//Hardware Instructions
#define bitcount __builtin_popcount
#define gcd __gcd

//Trasersal Macros
#define rep(i,n) for(int i=0, _##i=(n); i<_##i; ++i)
#define dwn(i,n) for(int i=(n); --i>=0; )
#define repr(i,l,r) for(int i=(l), _##i=(r); i<=_##i; ++i)
#define dwnr(i,l,r) for(int i=(r), _##i=(l); --i>=_##i; )
#define repi(i,a) for(__typeof((a).begin()) i=(a).begin(), _##i=(a).end(); i!=_##i; ++i)
#define dwni(i,a) for(__typeof((a).rbegin()) i=(a).rbegin(), _##i=(a).rend(); i!=_##i; ++i)
#define all(a) a.begin(),a.end()
#define fill(a,s) memset(a,s,sizeof(a));
#define ff first
#define ss second
#define abs(x) (x<0?(-x):x)
#define EPS 1e-9

using namespace std;
const ll MX=100000;
const ll MOD = 1000000007;
const int base = 131;
const int inf = 222222222;
ll fast_exp(ll base,ll exp,ll mod){
  ll res=1;
  while(exp > 0){
    if (exp%2==1)res=(res*base)%mod;
    base = (base*base)%mod;
    exp/=2;
   }
  return res;
}
ll inv(ll a,ll m){
  /* Remember m must be a prime */ return fast_exp(a,m-2,m);
}
ll a[222][222];
ll city[222];
int main(){

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n,m;
  cin >> n >> m;

  for (int i=1; i <= n ; i++){
    for (int j=1; j <= m ; j++){
      cin >> a[i][j];
    }
  }

  for (int i=1; i <= n ; i++){
    ll mx = 0;
    ll idx = 1;
    for (int j=1; j <= m ; j++){
      if (a[i][j] > mx){
        mx = a[i][j];
        idx = j;
      }
    }
    ++city[idx];
  }

  ll ans = 0;
  ll idx = 1;
  for (int i=1; i <= m ; i++){
    if (city[i] > ans){
      ans = city[i];
      idx = i;
    }
  }
  cout << idx;
  return 0;

}


/* sidchelseafan */
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define INF (ll)1e12
#define sz(a) (int)a.size()
#define pii pair<int,int>
#define pll pair<ll,ll>

//Hardware Instructions
#define bitcount __builtin_popcount
#define gcd __gcd

//Trasersal Macros
#define rep(i,n) for(int i=0, _##i=(n); i<_##i; ++i)
#define dwn(i,n) for(int i=(n); --i>=0; )
#define repr(i,l,r) for(int i=(l), _##i=(r); i<=_##i; ++i)
#define dwnr(i,l,r) for(int i=(r), _##i=(l); --i>=_##i; )
#define repi(i,a) for(__typeof((a).begin()) i=(a).begin(), _##i=(a).end(); i!=_##i; ++i)
#define dwni(i,a) for(__typeof((a).rbegin()) i=(a).rbegin(), _##i=(a).rend(); i!=_##i; ++i)
#define all(a) a.begin(),a.end()
#define fill(a,s) memset(a,s,sizeof(a));
#define ff first
#define ss second
#define abs(x) (x<0?(-x):x)
#define EPS 1e-9

using namespace std;
const ll MX=100000;
const ll MOD = 1000000007;
const int base = 131;
const int inf = 222222222;
ll fast_exp(ll base,ll exp,ll mod){
  ll res=1;
  while(exp > 0){
    if (exp%2==1)res=(res*base)%mod;
    base = (base*base)%mod;
    exp/=2;
   }
  return res;
}
ll inv(ll a,ll m){
  /* Remember m must be a prime */ return fast_exp(a,m-2,m);
}
ll a[222][222];
ll city[222];
int main(){

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n,m;
  cin >> n >> m;

  for (int i=1; i <= n ; i++){
    for (int j=1; j <= m ; j++){
      cin >> a[i][j];
    }
  }

  for (int i=1; i <= n ; i++){
    ll mx = -1;
    ll idx = -1;
    for (int j=1; j <= m ; j++){
      if (a[i][j] > mx){
        mx = a[i][j];
        idx = j;
      }
    }
    city[i] = idx;
  }

  map<ll,ll> win;
  for (int i=1; i <= n ; i++){
    ++win[city[i]];
  }

  ll ans = -1;
  ll idx = -1;
  for (auto it = win.begin(); it != win.end(); it++){
    if (it->second > ans){
      ans = it->second;
      idx = it->first;
    }
    else if (it->second==ans){
      if (it->first < idx)
        idx = it->first;
    }
  }
  cout << idx;
  return 0;

}


/* sidchelseafan */
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define INF (ll)1e12
#define sz(a) (int)a.size()
#define pii pair<int,int>
#define pll pair<ll,ll>

//Hardware Instructions
#define bitcount __builtin_popcount
#define gcd __gcd

//Trasersal Macros
#define rep(i,n) for(int i=0, _##i=(n); i<_##i; ++i)
#define dwn(i,n) for(int i=(n); --i>=0; )
#define repr(i,l,r) for(int i=(l), _##i=(r); i<=_##i; ++i)
#define dwnr(i,l,r) for(int i=(r), _##i=(l); --i>=_##i; )
#define repi(i,a) for(__typeof((a).begin()) i=(a).begin(), _##i=(a).end(); i!=_##i; ++i)
#define dwni(i,a) for(__typeof((a).rbegin()) i=(a).rbegin(), _##i=(a).rend(); i!=_##i; ++i)
#define all(a) a.begin(),a.end()
#define fill(a,s) memset(a,s,sizeof(a));
#define ff first
#define ss second
#define abs(x) (x<0?(-x):x)
#define EPS 1e-9

using namespace std;
const ll MX=100000;
const ll MOD = 1000000007;
const int base = 131;
const int inf = 222222222;
ll fast_exp(ll base,ll exp,ll mod){
  ll res=1;
  while(exp > 0){
    if (exp%2==1)res=(res*base)%mod;
    base = (base*base)%mod;
    exp/=2;
   }
  return res;
}
ll inv(ll a,ll m){
  /* Remember m must be a prime */ return fast_exp(a,m-2,m);
}
ll a[222][222];
ll city[222];
int main(){

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n,m;
  cin >> n >> m;

  for (int i=1; i <= m ; i++){
    for (int j=1; j <= n ; j++){
      cin >> a[i][j];
    }
  }

  for (int i=1; i <= m ; i++){
    ll mx = 0;
    ll idx = 1;
    for (int j=1; j <= n ; j++){
      if (a[i][j] > mx){
        mx = a[i][j];
        idx = j;
      }
    }
    ++city[idx];
  }

  ll ans = 0;
  ll idx = 1;
  for (int i=1; i <= m ; i++){
    if (city[i] > ans){
      ans = city[i];
      idx = i;
    }
  }
  cout << idx;
  return 0;

}


/* sidchelseafan */
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define INF (ll)1e12
#define sz(a) (int)a.size()
#define pii pair<int,int>
#define pll pair<ll,ll>

//Hardware Instructions
#define bitcount __builtin_popcount
#define gcd __gcd

//Trasersal Macros
#define rep(i,n) for(int i=0, _##i=(n); i<_##i; ++i)
#define dwn(i,n) for(int i=(n); --i>=0; )
#define repr(i,l,r) for(int i=(l), _##i=(r); i<=_##i; ++i)
#define dwnr(i,l,r) for(int i=(r), _##i=(l); --i>=_##i; )
#define repi(i,a) for(__typeof((a).begin()) i=(a).begin(), _##i=(a).end(); i!=_##i; ++i)
#define dwni(i,a) for(__typeof((a).rbegin()) i=(a).rbegin(), _##i=(a).rend(); i!=_##i; ++i)
#define all(a) a.begin(),a.end()
#define fill(a,s) memset(a,s,sizeof(a));
#define ff first
#define ss second
#define abs(x) (x<0?(-x):x)
#define EPS 1e-9

using namespace std;
const ll MX=100000;
const ll MOD = 1000000007;
const int base = 131;
const int inf = 222222222;
ll fast_exp(ll base,ll exp,ll mod){
  ll res=1;
  while(exp > 0){
    if (exp%2==1)res=(res*base)%mod;
    base = (base*base)%mod;
    exp/=2;
   }
  return res;
}
ll inv(ll a,ll m){
  /* Remember m must be a prime */ return fast_exp(a,m-2,m);
}
ll a[222][222];
ll city[222];
int main(){

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n,m;
  cin >> n >> m;

  for (int i=1; i <= m ; i++){
    for (int j=1; j <= n ; j++){
      cin >> a[i][j];
    }
  }

  fill(city,0);
  for (int i=1; i <= m ; i++){
    ll mx = 0;
    ll idx = 1;
    for (int j=1; j <= n ; j++){
      if (a[i][j] > mx){
        mx = a[i][j];
        idx = j;
      }
    }
    ++city[idx];
  }

  ll ans = 0;
  ll idx = 1;
  for (int i=1; i <= n ; i++){
    if (city[i] > ans){
      ans = city[i];
      idx = i;
    }
  }
  cout << idx;
  return 0;

}


/* sidchelseafan */
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define INF (ll)1e12
#define sz(a) (int)a.size()
#define pii pair<int,int>
#define pll pair<ll,ll>

//Hardware Instructions
#define bitcount __builtin_popcount
#define gcd __gcd

//Trasersal Macros
#define rep(i,n) for(int i=0, _##i=(n); i<_##i; ++i)
#define dwn(i,n) for(int i=(n); --i>=0; )
#define repr(i,l,r) for(int i=(l), _##i=(r); i<=_##i; ++i)
#define dwnr(i,l,r) for(int i=(r), _##i=(l); --i>=_##i; )
#define repi(i,a) for(__typeof((a).begin()) i=(a).begin(), _##i=(a).end(); i!=_##i; ++i)
#define dwni(i,a) for(__typeof((a).rbegin()) i=(a).rbegin(), _##i=(a).rend(); i!=_##i; ++i)
#define all(a) a.begin(),a.end()
#define fill(a,s) memset(a,s,sizeof(a));
#define ff first
#define ss second
#define abs(x) (x<0?(-x):x)
#define EPS 1e-9

using namespace std;
const ll MX=100000;
const ll MOD = 1000000007;
const int base = 131;
const int inf = 222222222;
ll fast_exp(ll base,ll exp,ll mod){
  ll res=1;
  while(exp > 0){
    if (exp%2==1)res=(res*base)%mod;
    base = (base*base)%mod;
    exp/=2;
   }
  return res;
}
ll inv(ll a,ll m){
  /* Remember m must be a prime */ return fast_exp(a,m-2,m);
}
ll a[222][222];
pll city[222];
int can[222];
int main(){

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n,m;
  cin >> n >> m;

  for (int i=1; i <= n ; i++){
    for (int j=1; j <= m ; j++){
      cin >> a[i][j];
    }
  }

  for (int i=1; i <= n ; i++){
    int mx = -1;
    int idx = -1;
    for (int j=1; j <= m ; j++){
      if (a[i][j] > mx){
        mx = a[i][j];
        idx = j;
      }
    }
    city[i] = mp(idx,mx);
  }

  map<int,int> win;
  for (int i=1; i <= n ; i++){
    ++win[city[i].ff];
  }

  int ans = -1;
  int idx = -1;
  for (auto it = win.begin(); it != win.end(); it++){
    if (it->second > ans){
      ans = it->second;
      idx = it->first;
    }
  }
  cout << idx;
  return 0;

}


#include <cstdio>

inline int read(){
	int _=0;char c=getchar();
	while(c>'9'||c<'0')c=getchar();
	while(c>='0'&&c<='9')_=_*10+c-48,c=getchar();return _;
}

#define I read()

int ans[105];

int main(){
	int n=I,m=I;
	for(int i=1;i<=m;++i){
		int ps=1,mx=-1,tmp;
		for(int j=1;j<=n;++j)
			if((tmp=I)>mx) ps=j,mx=tmp;
		ans[ps]++;
	}
	int mx=0,id=1;
	for(int i=1;i<=n;++i)
		if(ans[i]>mx) id=i,mx=ans[i];
	printf("%d",id);
	return 0;
}


#include<iostream>
using namespace std;
int n,m,a[105][105],ans[105],maxn=~0x3f,maxcandidate;
int main(){
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        for(int j=1;j<=n;j++){
            cin>>a[i][j];
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            ans[i]+=a[i][j];
        }
    }
    for(int i=1;i<=n;i++){
        if(ans[i]>maxn){
            maxn=ans[i];
            maxcandidate=i;
        }
    }
    cout<<maxcandidate<<endl;
    return 0;
}


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

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

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

	maxn = -1, peo = -1;
	F(i, 1, N){//统计出最大票数
		if (w[i] > maxn){
			maxn = w[i];
			peo = i;
		}
	}//F(i, 1, N){//找RealCandidata的最大值的下标
	cout << peo << endl;
	return 0;
}


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

int N, M, a[102][102];
int ans[102], candidate[102];
int RealCandidate[102], RealAns, flag;

int main()
{
	IOS;
	//FO;
	cin >> N >> M;
	F(i, 1, N){
		F(j, 1, M){
			cin >> a[i][j];
			if (a[i][j] > ans[i]){
				ans[i] = a[i][j];
				candidate[i] = j;//第i个城市选第j个人
			}
		}
		RealCandidate[candidate[i]]++;
	}

	F(i, 1, N){//找RealCandidata的最大值的下标
		if (RealCandidate[i] > flag){
			flag = RealCandidate[i];
			RealAns = i;
		}
	}//F(i, 1, N){//找RealCandidata的最大值的下标
	cout << RealAns << endl;
	return 0;
}


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


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


#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
const int maxn = 1e5+10;
int n,m;
int cnt[maxn];
vector<int>a[maxn];
int p[maxn],c[maxn];

int main()
{
    scanf("%d%d",&n,&m);
    for(int i = 1;i<=n;i++)
    {
        scanf("%d%d",&p[i],&c[i]);
        a[p[i]].push_back(c[i]);
        cnt[p[i]]++;
    }
    for(int i = 1;i<=m;i++)
    {
        sort(a[i].begin(),a[i].end());
        reverse(a[i].begin(),a[i].end());
    }
    ll ans = 1e18;
    for(int i = 1;i<=n;i++)
    {
        ll tmp = 0;
        int c = 0;
        vector<int>can;
        for(int j = 2;j<=m;j++)
        {
            int t = min(i-1,(int)a[j].size());
            for(int k = 0;k<t;k++)
                can.push_back(a[j][k]);
            for(int k = t;k<(int)a[j].size();k++)
            {
                tmp+=a[j][k];
                c++;
            }
        }
        sort(can.begin(),can.end());
        for(int j = 0;j<i-cnt[1]-c;j++)
            tmp+=can[j];
        ans = min(ans,tmp);
    }
    cout<<ans;
    return 0;
}


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


#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
const int N=110;
#define ll long long
ll a[N][N];
int n,m;
int main()
{
    ll res=0;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    for(int j=1;j<=n;j++)
    {
        scanf("%lld",&a[i][j]);
        a[i][j]+=a[i-1][j];
    }
    for(int i=1;i<=n;i++)
    {
        res=max(res,a[m][i]);
    }
    for(int i=1;i<=n;i++)
    if(res==a[m][i])
    {
        printf("%d\n",i);
        break;
    }
    return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int n,m;
struct p{
	int cnt,sum;
};p ma;
struct s{
	int cnt,a;
};s b[101];
int cmp(s x,s y){
	return x.a>y.a||(x.a==y.a&&x.cnt<y.cnt);
}
int main(){
	cin>>n>>m;
	ma.cnt=100000;
	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++){
			cin>>b[j].a;
			b[j].cnt=j;
		}
		sort(b+1,b+n+1,cmp);
		if(b[1].a>=ma.sum&&b[1].cnt<ma.cnt){
			ma.sum=b[1].a;ma.cnt=b[1].cnt;
		}
	}
	cout<<ma.cnt;
	return 0;
}


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


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


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    while(cin>>n>>m)
    {
        int p[n+1]= {0};
        int a;
        for(int i=1; i<=m; i++)
        {
            int q=-1,w=-1;
            for(int j=1; j<=n; j++)
            {
                cin>>a;
                if(a>q)
                {
                    q=a;
                    w=j;
                }
            }
              p[w]++;
        }
        int t=-1;
        for(int i=1; i<=n; i++)
        {
          if(t<p[i]) t=p[i];
        }

        for(int i=1; i<=n; i++)
        {
            if(p[i]==t)
            {
                 cout<<i<<endl;
                 break;
            }

        }
    }
     return 0;
}


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


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

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

    cout << l << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int MAXN=105;
int n,m,a[MAXN]={-11000},x,t;
int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++)
		for(int i=1;i<=n;i++){
			cin>>x;
			a[i]+=x;
		}
	for(int i=n;i>=1;i--)if(a[t]<=a[i])t=i;
    printf("%d",t);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,m,a,peo,maxn,maxp,vot[105]={0};
int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		peo=maxp=-0x7FFFF;
		for(int j=1;j<=n;j++){
			cin>>a;
			if(a>maxp){
				maxp=a;
				peo=j;
			}
		}
		vot[peo]++;
	}
	for(int i=1;i<=n;i++){
		if(vot[i]>maxn){
			maxn=vot[i];
		}
	}
	for(int i=1;i<=n;i++){
		if(vot[i]==maxn){
			cout<<i<<endl;
			return 0;
		}
	}
}


#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int maxn = 150;
ll n, m;

struct node{
    ll id;
    ll v;
//    friend bool operator <(node x, node y){
//        if( x.v==y.v ) return x.id<y.id;
//        else return x.v>y.v;
//    }
}a[maxn];

bool cmp(node x, node y){
    if( x.v==y.v ) return x.id<y.id;
    return x.v>y.v;
}

int main()
{
    scanf("%lld%lld",&n,&m);
    for(register ll j=1;j<=m;j++){
        for(register ll i=1;i<=n;i++){
            ll num;
            scanf("%lld",&num);
            a[i].v+=num;
            a[i].id = i;
        }
    }

    sort(a+1, a+n+1,cmp);
    ll pos=-1;
    ll maxx=-1;
    for(register ll i=1;i<=n;i++){
        if( a[i].v>maxx ){
            maxx = a[i].v;
            pos = a[i].id;
        }
    }
    printf("%lld\n",pos);
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=110;
int num[N],a[N][N];
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        int ans,mx=-2e9;
        for(int j=1;j<=n;j++)
        {
            cin>>a[i][j];
            if(mx<a[i][j]) mx=a[i][j],ans=j;
        }
        num[ans]++;
    }
    int mx=0,res;
    for(int i=1;i<=n;i++)
        if(mx<num[i]) mx=num[i],res=i;
    cout<<res<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[101][101];
int p[200];
int maxnum;
int maxx;
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		maxx=0;
		for(int j=1;j<=m;j++)
		{
			cin>>a[i][j];
			if(a[i][j]>maxx)
			{
				maxnum=j;
				maxx=a[i][j];
			}
		}
		p[maxnum]++;
	}
	cout<<endl;
	int ans=0,maxn=0;
	for(int i=1;i<=199;i++)
	{
		if(p[i]>maxn)
		{
			ans=i;maxn=p[i];
		}
	}
	cout<<ans<<endl;
	return 0;
 }


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


#include<bits/stdc++.h>
#define mem(i,j) memset(i,j,sizeof(i))
#define Endl printf("\n")
#define ka printf(" ")
using namespace std;
inline int read(){
    int res=0,f=1;char ch=' ';
    while(!isdigit(ch)){if(ch=='-') f=-1;ch=getchar();}
    while(isdigit(ch)){res=res*10+ch-'0';ch=getchar();}
    return res*f;
}
void write(int x){
    if(x<0){putchar('-');x=-x;}
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
const int N=1e2+5;
int n,m,tot,maxn[N],maxv,name,peo[N];
struct node{
    int a,x,y;
}q[N];
int main() {
    n=read(),m=read();
    int k=m;
    for(register int i=1;i<=m;i++)
        for(register int j=1;j<=n;j++)
            q[++tot].a=read(),q[tot].x=i,q[tot].y=j;
    m++;
    while(m--)
        for(register int i=1;i<=tot;i++){
            if(q[i].x!=m)continue;
            if(q[i].a>maxn[m])maxn[m]=q[i].a,peo[m]=q[i].y;
            else if(q[i].a==maxn[m]&&q[i].y<peo[m])peo[m]=q[i].y;
        }
    for(register int i=1;i<=k;i++){
        if(maxv<maxn[i])maxv=maxn[i],name=peo[i];
        else if(maxn[i]==maxv&&peo[i]<name)name=peo[i];
    }
    write(name);
}


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


#include <bits/stdc++.h>
#define re register int
using namespace std;
int n,m;
struct erection
{
	int hm;
	int score;
}a[101];
inline bool cmp(erection x,erection y)
{
	if(x.score==y.score)
		return x.hm<y.hm;
	return x.score>y.score;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(re i=1;i<=n;i++)
		a[i].hm=i;
	for(re i=1;i<=m;i++)
		for(re j=1;j<=n;j++)
		{
			re x;
			scanf("%d",&x);
			a[j].score+=x;
		}
	sort(a+1,a+n+1,cmp);
	printf("%d",a[1].hm);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int s[1100];
int main()
{
	int n,m;
	int maxn=0,ans;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		maxn=0;
		ans=0;
		for(int j=1;j<=n;j++)
		{
			int a;
			scanf("%d",&a);
			if(maxn<a){maxn=a;ans=j;}
		}
		s[ans]++;
	}
	ans=0;
	maxn=0;
	for(int i=1;i<=n;i++)
	{
		if(maxn<s[i])
		{
			maxn=s[i];
			ans=i;
		}
	}
	printf("%d",ans);
	return 0;
}


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


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


#include<bits/stdc++.h>
using namespace std;
int a[101][101];
int p[200];
int maxnum;
int maxx;
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		maxx=0;
		for(int j=1;j<=m;j++)
		{
			cin>>a[i][j];
			if(a[i][j]>maxx)
			{
				maxnum=j;
				maxx=a[i][j];
			}
		}
		cout<<maxnum<<" ";
		p[maxnum]++;
	}
	cout<<endl;
	int ans=0,maxn=0;
	for(int i=1;i<=199;i++)
	{
		cout<<p[i]<<" ";
		if(p[i]>maxn)
		{
			ans=i;maxn=p[i];
		}
	}
	cout<<ans<<endl;
	return 0;
 }


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


#include <iostream>
using namespace std;
int a[100001],b[100001],maxl=-1,maxt;
int main(){
	int i,j,k,n,m;
	cin>>n>>m;
	for(i=1;i<=m;i++){
		maxl=-1;
	    for(j=1;j<=n;j++){
		    cin>>b[j];
		    if(maxl<b[j])maxl=b[j],maxt=j;
		}
	    a[maxt]++;
	}
	maxl=-1;
	maxt=-1;
	for(i=1;i<=m;i++)
	if(maxl<a[i])maxl=a[i],maxt=i;
	cout<<maxt<<endl;
	return 0;
}


#include <cstdio>
#include <iostream>
using namespace std;
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <stack>
#include <map>
#include <list>
#include <deque>
#include <climits>
#include <algorithm>
#include <cstdlib>
#define ll long long
#define MOD 1000000007
#define N 110
#define R register int

ll n,m,x,maxx,ans;
ll pp[N];

int main()
{
	cin>>n>>m;
	memset(pp,-1,sizeof(pp));
	maxx=-1;
	for (R i=1;i<=m;i++)
	{
		for (R j=1;j<=n;j++)
		{
			cin>>x;
			pp[j]+=x;
		}
	}
	for (R i=n;i>=1;i--)
	{
		if (pp[i]>=maxx)
		{
			maxx=pp[i];
			ans=i;
		}
	}
	cout<<ans<<endl;
 	return 0;
}


#include<iostream>
using namespace std;
int n,m;//n个候选人，m座城市
int a,zuiniubidehouxuanren;//变量名皮一下我很开心
int maxn,zuiniubidehouxuanrenmax;
int main()
{
	cin>>n>>m;
	int c[n+1]={0};//存放候选人票数
	for(int i=1;i<=m;i++)
	{
		zuiniubidehouxuanren=-1;//这两个变量必须每次更新到
        //-1！！！！原因：每个城市可以一张票都不投
		zuiniubidehouxuanrenmax=-1;//本蒟蒻就是因为一开始
        //每次更新到0而WA了第43还是第47个测试点
		for(int j=1;j<=n;j++)
		{
			cin>>a;
			if(a>zuiniubidehouxuanrenmax)//先弄出每个城市投的
			{
				zuiniubidehouxuanrenmax=a;
				zuiniubidehouxuanren=j;
			}
		}
		c[zuiniubidehouxuanren]++;//这位候选人的票数+1
	}
    int loc=0;
	for(int i=1;i<=n;i++)
	{
		if(c[i]>maxn)maxn=c[i],loc=i;//先找出票数最大值
	}
    printf("%d\n",loc);
    return 0;
}


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


#include <cstdio>
#include <iostream>
using namespace std;
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <stack>
#include <map>
#include <list>
#include <deque>
#include <climits>
#include <algorithm>
#include <cstdlib>
#define ll long long
#define MOD 1000000007
#define N 110
#define R register int

ll n,m,x,maxx,ans;
ll pp[N];

int main()
{
	cin>>n>>m;
	for (R i=1;i<=m;i++)
	{
		for (R j=1;j<=n;j++)
		{
			cin>>x;
			pp[j]+=x;
		}
	}
	for (R i=n;i>=1;i--)
	{
		if (pp[i]>=maxx)
		{
			maxx=pp[i];
			ans=i;
		}
	}
	cout<<ans<<endl;
 	return 0;
}


#include <iostream>
using namespace std;
int a[100001],maxl=-1,maxt;
int main(){
	int i,j,k,n,m;
	cin>>n>>m;
	for(i=1;i<=m;i++)
	for(j=1;j<=n;j++){
		cin>>k;
		a[j]+=k;
	}
	for(i=1;i<=n;i++)
	if(maxl<a[i]){
		maxl=a[i];
		maxt=i;
	}
	cout<<maxt<<endl;
	return 0;
}


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


#include<bits/stdc++.h>
using namespace std;
int s[110];
int main()
{
	int n,m;
	int maxn=0,ans;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		maxn=0;
		for(int j=1;j<=n;j++)
		{
			int a;
			scanf("%d",&a);
			if(maxn<a){maxn=a;ans=j;}
		}
		s[ans]++;
	}
	ans=0;
	maxn=0;
	for(int i=1;i<=n;i++)
	{
		if(maxn<s[i])
		{
			maxn=s[i];
			ans=i;
		}
	}
	printf("%d",ans);
	return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<fstream>
#include<cmath>
#include<vector>
#include <bits/stdc++.h>
#include<sstream>
using namespace std;
int main()
{
    int n,m,s,g=0,k=0,z,x;
    cin>>n>>m;
    if (n>=m)
        {
            z=n;x=m;
        }
    else
        {
            z=m;x=n;
        }
    int a[z][x];
    int v[z];
    for (int i=0;i<z;i++)
        {
            for (int j=0;j<x;j++)
                {
                    cin>>a[i][j];
                }
            s=a[i][0];
            for (int j=0;j<x;j++)
                {
                    if (s<a[i][j])
                        {
                            s=a[i][j];g=j+1;
                        }
                }
            if (g==0){v[k]=1;}
            else{v[k]=g;}
            k++;g=0;
        }
    sort(v,v+k);
    cout<<v[0]<<endl;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<fstream>
#include<cmath>
#include<vector>
#include <bits/stdc++.h>
#include<sstream>
using namespace std;
int main()
{
    int n,m,s,g=0,k=0,z,x;
    cin>>n>>m;
    int a[m][n];
    int v[n];
    for (int i=0;i<m;i++)
        {
            for (int j=0;j<n;j++)
                {
                    cin>>a[i][j];
                }
            s=a[i][0];
            for (int j=0;j<n;j++)
                {
                    if (s<a[i][j])
                        {
                            s=a[i][j];g=j+1;
                        }
                }
            if (g==0){v[k]=1;}
            else{v[k]=g;}
            k++;g=0;
        }
    sort(v,v+k);
    cout<<v[0]<<endl;


#include<iostream>
#include<string>
#include<algorithm>
#include<fstream>
#include<cmath>
#include<vector>
#include <bits/stdc++.h>
#include<sstream>
using namespace std;
int main()
{
    int n,m,s,g=0,k=0,z,x;
    cin>>n>>m;
    int a[m][n];
    int v[n];
    for (int i=0;i<m;i++)
        {
            for (int j=0;j<n;j++)
                {
                    cin>>a[i][j];
                }
            s=a[i][0];
            for (int j=0;j<n;j++)
                {
                    if (s<a[i][j])
                        {
                            g=0;
                            s=a[i][j];g=j+1;
                        }
                }
            if (g==0){v[k]=1;}
            else{v[k]=g;}
            k++;g=0;
        }
    sort(v,v+k);
    cout<<v[0]<<endl;
}


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


#include<iostream>
#include<string>
#include<algorithm>
#include<fstream>
#include<cmath>
#include<vector>
#include <bits/stdc++.h>
#include<sstream>
using namespace std;
int main()
{
    int n,m,s,g=0,k=0,z,x;
    cin>>n>>m;
    int a[m][n];
    int v[m];
    for (int i=0;i<m;i++)
        {
            for (int j=0;j<n;j++)
                {
                    cin>>a[i][j];
                }
            s=a[i][0];
            for (int j=0;j<n;j++)
                {
                    if (s<a[i][j])
                        {
                            s=a[i][j];g=j+1;
                        }
                }
            if (g==0){v[k]=1;}
            else{v[k]=g;}
            k++;g=0;
        }
    sort(v,v+k);
    cout<<v[0]<<endl;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<fstream>
#include<cmath>
#include<vector>
#include <bits/stdc++.h>
#include<sstream>
using namespace std;
int main()
{
    int n,m,s,g=0,k=0,z,x,u=0;
    cin>>n>>m;
    int a[m][n];
    int v[m],c[m],b[m];
    for (int i=0;i<m;i++)
        {
            for (int j=0;j<n;j++)
                {
                    cin>>a[i][j];
                }
            s=a[i][0];
            for (int j=0;j<n;j++)
                {
                    if (s<a[i][j])
                        {
                            s=a[i][j];g=j+1;
                        }
                }
            c[k]=s;
            if (g==0){v[k]=1;}
            else{v[k]=g;}
            k++;g=0;
        }
    s=0;
    g=0;
    s=c[0];
    for (int j=0;j<k;j++)
        {
            if (s<c[j])
                {
                    s=c[j];
                }
            if (s>c[j]){v[j]=0;u++;}
            if (s==c[j]){g++;}
        }
    if (g>1)
        {
            sort(v,v+k);
            cout<<v[u]<<endl;
            return 0;
        }
    else
        {
            sort(v,v+k);
            cout<<v[u]<<endl;
            return 0;
        }
}


#include<iostream>
#include<string>
#include<algorithm>
#include<fstream>
#include<cmath>
#include<vector>
#include <bits/stdc++.h>
#include<sstream>
using namespace std;
int main()
{
    int n,m,s,g=0,k=0,z,x;
    cin>>n>>m;
    int a[m][n];
    int v[n];
    for (int i=0;i<m;i++)
        {
            for (int j=0;j<n;j++)
                {
                    cin>>a[i][j];
                }
            s=a[i][0];
            for (int j=0;j<n;j++)
                {
                    if (s<a[i][j])
                        {
                            s=a[i][j];g=j+1;
                        }
                }
            if (g==0){v[k]=1;}
            else{v[k]=g;}
            k++;g=0;
        }
    sort(v,v+k);
    cout<<v[0]<<endl;
}


#include<iostream>
using namespace std;
int main()
{
    long long n,m,a[100][100],vote[100000]={0},winner=0,win[10000],elec[100000]={0};
    cin>>n>>m;
    for(int i=0;i<m;i++)
        {
            winner=0;
            for(int j=0;j<n;j++)
            {
                cin>>a[i][j];
                win[i]=max(a[i][j],winner);
                winner=win[i];
            }
        }
    if (n==1) cout<<"1";
    else
    {
        for(int i=0;i<m;i++)
        {
            for(int j=0;j<n;j++)
            {
                if (a[i][j]==win[i]) {a[i][j]=1; win[i]=-5;}
                else if (a[i][j]!=win[i]) a[i][j]=0;
            }
        }
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                elec[i]=a[j][i]+elec[i];
            }
        }
        for(int i=0;i<n-1;i++)
        {
            winner=max(elec[i],elec[i+1]);
        }
        for(int i=0;i<n;i++)
        {
            if (elec[i]==winner) {cout<<i+1; break;}
        }
    }
}


#include<iostream>
using namespace std;
int main()
{
    long long n,m,a[100][100],v=0,winner=0,win[10000],elec[100000]={0};
    cin>>n>>m;
    for(int i=0;i<m;i++)
        {
            winner=0;
            for(int j=0;j<n;j++)
            {
                cin>>a[i][j];
                win[i]=max(a[i][j],winner);
                winner=win[i]; v=i+1;
            }
        }
    if (n==1) cout<<"1";
    else if(m==1)
    {
        for(int i=0;i<n;i++)
        {
            if (a[0][i]==winner) cout<<i+1;
        }
    }
    else
    {
        for(int i=0;i<m;i++)
        {
            for(int j=0;j<n;j++)
            {
                if (a[i][j]==win[i]) {a[i][j]=1; win[i]=-5;}
                else if (a[i][j]!=win[i]) a[i][j]=0;
            }
        }
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                elec[i]=a[j][i]+elec[i];
            }
        }
        for(int i=0;i<n-1;i++)
        {
            winner=max(elec[i],elec[i+1]);
        }
        for(int i=0;i<n;i++)
        {
            if (elec[i]==winner) {cout<<i+1; break;}
        }
    }
}


#include<iostream>
using namespace std;
int main()
{
    long long n,m,a[100][100],v=0,winner=0,win[10000],elec[100000]={0};
    cin>>n>>m;
    for(int i=0;i<m;i++)
        {
            winner=0;
            for(int j=0;j<n;j++)
            {
                cin>>a[i][j];
                win[i]=max(a[i][j],winner);
                winner=win[i]; v=i+1;
            }
        }
    if (n==1) cout<<"1";
    else if(m==1) cout<<v;
    else
    {
        for(int i=0;i<m;i++)
        {
            for(int j=0;j<n;j++)
            {
                if (a[i][j]==win[i]) {a[i][j]=1; win[i]=-5;}
                else if (a[i][j]!=win[i]) a[i][j]=0;
            }
        }
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                elec[i]=a[j][i]+elec[i];
            }
        }
        for(int i=0;i<n-1;i++)
        {
            winner=max(elec[i],elec[i+1]);
        }
        for(int i=0;i<n;i++)
        {
            if (elec[i]==winner) {cout<<i+1; break;}
        }
    }
}


#include<iostream>
using namespace std;
int main()
{
    long long n,m,a[100][100],vote[100000]={0},win=0;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
    for(int j=0;j<n;j++)
    {
        cin>>a[i][j];
        vote[j]=vote[j]+a[i][j];
    }
    }
    for(int i=0;i<n-1;i++)
    {
        win=max(vote[i],vote[i+1]);
    }
    if(n=1) cout<<"1";
    else
    for(int i=0;i<n;i++)
    {
        if (vote[i]==win) {cout<<i+1; break;}
    }
}


#include<iostream>
using namespace std;
int main()
{
    long long n,m,a[100][100],vote[100000]={0},win=0;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
    for(int j=0;j<n;j++)
    {
        cin>>a[i][j];
        vote[j]=vote[j]+a[i][j];
    }
    }
    for(int i=0;i<n-1;i++)
    {
        win=max(vote[i],vote[i+1]);
    }
    if(n==1) cout<<"1";
    else
    for(int i=0;i<n;i++)
    {
        if (vote[i]==win) {cout<<i+1; break;}
    }
}


#include<iostream>
using namespace std;
int main()
{
    long long n,m,a[100][100],vote[100000]={0},winner=0,win[10000],elec[100000]={0};
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
    winner=0;
    for(int j=0;j<n;j++)
    {
        cin>>a[i][j];
        win[i]=max(a[i][j],winner);
        winner=win[i];
    }
    }
    for(int i=0;i<m;i++)
    {
        for(int j=0;j<n;j++)
        {
            if (a[i][j]==win[i]) {a[i][j]=1; win[i]=-5;}
            else if (a[i][j]!=win[i]) a[i][j]=0;
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            elec[i]=a[j][i]+elec[i];
        }
    }
    for(int i=0;i<n-1;i++)
    {
        winner=max(elec[i],elec[i+1]);
    }
    for(int i=0;i<n;i++)
    {
        if (elec[i]==winner) {cout<<i+1; break;}
    }
}


#include<iostream>
using namespace std;
int main()
{
    long long n,m,a[100][100],vote[100000]={0},win=0;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
    for(int j=0;j<n;j++)
    {
        cin>>a[i][j];
        vote[j]=vote[j]+a[i][j];
    }
    }
    for(int i=0;i<m-1;i++)
    {
        win=max(vote[i],vote[i+1]);
    }
    for(int i=0;i<n;i++)
    {
        if (vote[i]==win) {cout<<i+1; break;}
    }
}


#include<iostream>
using namespace std;
int main()
{
    long long n,m,a[100][100],vote[100000]={0},win=0;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
    for(int j=0;j<n;j++)
    {
        cin>>a[i][j];
        vote[j]=vote[j]+a[i][j];
    }
    }
    for(int i=0;i<n-1;i++)
    {
        win=max(vote[i],vote[i+1]);
    }
    for(int i=0;i<n;i++)
    {
        if (vote[i]==win) {cout<<i+1; break;}
    }
}


#include<iostream>
using namespace std;
int main()
{
    long long n,m,a[100][100],v=0,winner=0,win[10000],elec[100000]={0};
    cin>>n>>m;
    for(int i=0;i<m;i++)
        {
            winner=0;
            for(int j=0;j<n;j++)
            {
                cin>>a[i][j];
                win[i]=max(a[i][j],winner);
                winner=win[i]; v=i+1;
            }
        }
    if (n==1) cout<<"1";
    else if(m==1)
    {
        for(int i=0;i<n;i++)
        {
            if (a[0][i]==winner) {cout<<i+1; break;}
        }
    }
    else
    {
        for(int i=0;i<m;i++)
        {
            for(int j=0;j<n;j++)
            {
                if (a[i][j]==win[i]) {a[i][j]=1; win[i]=-5;}
                else if (a[i][j]!=win[i]) a[i][j]=0;
            }
        }
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                elec[i]=a[j][i]+elec[i];
            }
        }
        for(int i=0;i<n-1;i++)
        {
            winner=max(elec[i],elec[i+1]);
        }
        for(int i=0;i<n;i++)
        {
            if (elec[i]==winner) {cout<<i+1; break;}
        }
    }
}


#include<iostream>
using namespace std;
int main()
{
    long long n,m,a[100][100],v=0,winner=0,win[10000],elec[100000]={0};
    cin>>n>>m;
    for(int i=0;i<m;i++)
        {
            winner=0;
            for(int j=0;j<n;j++)
            {
                cin>>a[i][j];
                win[i]=max(a[i][j],winner);
                winner=win[i]; v=i+1;
            }
        }
    for(int i=0;i<m;i++)
    {
        for(int j=0;j<n;j++)
        {
            if (a[i][j]==win[i]) {a[i][j]=1; win[i]=-5;}
            else if (a[i][j]!=win[i]) a[i][j]=0;
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            elec[i]=a[j][i]+elec[i];
        }
    }
    winner=0;
    for(int i=0;i<n;i++)
    {
        winner=max(elec[i],winner);
    }
    for(int i=0;i<n;i++)
    {
        if (elec[i]==winner) {cout<<i+1; break;}
    }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    map<int,int>myMap;
    int maxi;
    int n,m;
    cin>>n>>m;
    int maxIndex[105]={0};
    int num;
    for(int i=1;i<=m;i++)
    {
        maxi=0;
        for(int j=1;j<=n;j++)
        {
            cin>>num;
            if(num>maxi)
            {
                maxIndex[i]=j;
                maxi=num;
            }
        }
    }

    for(int i=1;i<=m;i++)
    {
        myMap[maxIndex[i]]++;
    }

    maxi=0;
    int ans=0;
    for(int i=1;i<=m;i++)
    {
        if(myMap[maxIndex[i]]>maxi)
        {
            ans=maxIndex[i];
            maxi=myMap[maxIndex[i]];
            myMap[maxIndex[i]]=0;
        }
    }
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    map<int,int>myMap;
    int maxi;
    int n,m;
    cin>>n>>m;
    int maxIndex[105]={0};
    int num;
    for(int i=1;i<=m;i++)
    {
        maxi=0;
        for(int j=1;j<=n;j++)
        {
            cin>>num;
            if(num>maxi)
            {
                maxIndex[i]=j;
                maxi=num;
            }
        }
    }

    for(int i=1;i<=m;i++)
    {
        myMap[maxIndex[i]]++;
    }

    maxi=0;
    int ans=0;
    for(int i=1;i<=m;i++)
    {
        if(myMap[maxIndex[i]]>maxi)
        {
            ans=maxIndex[i];
            maxi=myMap[maxIndex[i]];
        }
    }
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long maxi;
    long long n,m;
    cin>>n>>m;
    long long maxIndex[105]={0};
    long long value[105]={0};
    long long num;
    for(long long i=1;i<=m;i++)
    {
        maxi=0;
        for(long long j=1;j<=n;j++)
        {
            cin>>num;
            if(num>maxi)
            {
                maxIndex[i]=j;
                maxi=num;
            }
        }
    }

    for(long long i=1;i<=m;i++)
    {
        value[maxIndex[i]]++;
    }

    maxi=0;
    long long ans=1;
    for(long long i=1;i<=m;i++)
    {
        if(value[i]>maxi)
        {
            ans=i;
            maxi=value[i];
        }
    }
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long maxi;
    long long n,m;
    cin>>n>>m;
    long long maxIndex[105]={0};
    long long value[105]={0};
    long long num;
    for(long long i=1;i<=m;i++)
    {
        maxi=0;
        for(long long j=1;j<=n;j++)
        {
            cin>>num;
            if(num>maxi)
            {
                maxIndex[i]=j;
                maxi=num;
            }
        }
    }
    for(long long i=1;i<=n;i++)
    {
        if(maxIndex[i]>0)
            value[maxIndex[i]]++;
    }

    maxi=0;
    long long ans=1;
    for(long long i=1;i<=n;i++)
    {
        if(value[i]>maxi)
        {
            ans=i;
            maxi=value[i];
        }
    }
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long maxi;
    long long n,m;
    cin>>n>>m;
    long long maxIndex[105]={0};
    long long value[105]={0};
    long long num;
    for(long long i=1;i<=m;i++)
    {
        maxi=-1;
        for(long long j=1;j<=n;j++)
        {
            cin>>num;
            if(num>maxi)
            {
                maxIndex[i]=j;
                maxi=num;
            }
        }
    }
    for(long long i=1;i<=n;i++)
    {
        if(maxIndex[i]>0)
            value[maxIndex[i]]++;
    }

    maxi=-1;
    long long ans=1;
    for(long long i=1;i<=n;i++)
    {
        if(value[i]>maxi)
        {
            ans=i;
            maxi=value[i];
        }
    }
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long maxi;
    long long n,m;
    cin>>n>>m;
    long long maxIndex[105]={0};
    long long value[105]={0};
    long long num;
    for(long long i=1;i<=m;i++)
    {
        maxi=0;
        for(long long j=1;j<=n;j++)
        {
            cin>>num;
            if(num>maxi)
            {
                maxIndex[i]=j;
                maxi=num;
            }
        }
    }

    for(long long i=1;i<=m;i++)
    {
        value[maxIndex[i]]++;
    }

    maxi=0;
    long long ans=0;
    for(long long i=1;i<=m;i++)
    {
        if(value[maxIndex[i]]>maxi)
        {
            ans=maxIndex[i];
            maxi=value[maxIndex[i]];
            value[maxIndex[i]]=0;
        }
    }
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    map<long,long>myMap;
    long maxi;
    long n,m;
    cin>>n>>m;
    long maxIndex[105]={0};
    long num;
    for(long i=1;i<=m;i++)
    {
        maxi=0;
        for(long j=1;j<=n;j++)
        {
            cin>>num;
            if(num>maxi)
            {
                maxIndex[i]=j;
                maxi=num;
                myMap[j]++;
            }
        }
    }
    maxi=0;
    long ans=0;
    for(int i=1;i<=m;i++)
    {
        if(myMap[maxIndex[i]]>maxi)
        {
            ans=maxIndex[i];
            maxi=myMap[maxIndex[i]];
        }
    }
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    map<long long,long long>myMap;
    long long maxi;
    long long n,m;
    cin>>n>>m;
    long long maxIndex[105]={0};
    long long num;
    for(long long i=1;i<=m;i++)
    {
        maxi=0;
        for(long long j=1;j<=n;j++)
        {
            cin>>num;
            if(num>maxi)
            {
                maxIndex[i]=j;
                maxi=num;
            }
        }
    }

    for(long long i=1;i<=m;i++)
    {
        myMap[maxIndex[i]]++;
    }

    maxi=0;
    long long ans=0;
    for(long long i=1;i<=m;i++)
    {
        if(myMap[maxIndex[i]]>maxi)
        {
            ans=maxIndex[i];
            maxi=myMap[maxIndex[i]];
            myMap[maxIndex[i]]=0;
        }
    }
    cout<<ans;
    return 0;
}


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

int main()
{
	int n,m,i,j,ma;
	cin>>n>>m;
	vector <int> v[n];
	ll arr[m][n];
	for(i=0;i<m;i++)
	for(j=0;j<n;j++)
	cin>>arr[i][j];
	for(i=0;i<m;i++)
	{
		ma=0;
		for(j=1;j<n;j++)
		{if(arr[i][j]>arr[i][ma])
		ma=j;
		}
	v[ma].push_back(i);
	}
	int k=0;
	for(i=1;i<n;i++)
	{	if(v[i].size()==0) continue;
		if(v[i].size()>v[k].size())
		k=i;
		else if(v[i].size()==v[k].size())
		{
			if
			(v[i][0]<v[k][0]) k=i;
		}
	}
printf("%d\n",k+1);
}


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

int main()
{
	int n,m,i,j,ma;
	cin>>n>>m;
	vector <int> v[n];
	ll arr[m][n];
	for(i=0;i<m;i++)
	for(j=0;j<n;j++)
	scanf("%I64d",arr[i][j]);
	for(i=0;i<m;i++)
	{
		ma=0;
		for(j=1;j<n;j++)
		{if(arr[i][j]>arr[i][ma])
		ma=j;
		}
	v[ma].push_back(i);
	}
	int k=0;
	for(i=1;i<n;i++)
	{
		if(v[i].size()>v[k].size())
		k=i;
		else if(v[i].size()==v[k].size())
		{
			if
			(v[i][0]<v[k][0]) k=i;
		}
	}
printf("%d\n",k+1);
}


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

int main()
{
	int n,m,i,j,ma;
	cin>>n>>m;
	vector <int> v[n];
	ll arr[m][n];
	for(i=0;i<m;i++)
	for(j=0;j<n;j++)
	cin>>arr[i][j];
	int mx=0,res=1;
	for(i=0;i<n;i++)
	{
		ma=0;
		for(j=0;j<m;j++)
		{
		ma+=arr[j][i];
		}
if(ma>mx) {
mx=ma;
res=i+1;
}
}
printf("%d\n",res);
}


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

int main()
{
    int n,m,i,j,ma;
    cin>>n>>m;
    vector <int> v[n];
    ll arr[m][n];
    for(i=0;i<m;i++)
    for(j=0;j<n;j++)
    cin>>arr[i][j];
    for(i=0;i<m;i++)
    {
        ma=0;
        for(j=1;j<n;j++)
        {if(arr[i][j]>arr[i][ma])
        ma=j;
        }
    v[ma].push_back(i);
    }
    int k=0;
    for(i=1;i<n;i++)
    {
        if(v[i].size()>v[k].size())
        k=i;
        else if(v[i].size()==v[k].size()&&v[i].size()!=0)
        {
            if
            (v[i][0]<v[k][0]) k=i;
        }
    }
printf("%d\n",k+1);
}


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

int main()
{
	int n,m,i,j,ma;
	cin>>n>>m;
	vector <int> v[n];
	ll arr[m][n];
	for(i=0;i<m;i++)
	for(j=0;j<n;j++)
	cin>>arr[i][j];
	for(i=0;i<m;i++)
	{
		ma=0;
		for(j=1;j<n;j++)
		{if(arr[i][j]>arr[i][ma])
		ma=j;
		}
	v[ma].push_back(i);
	}
	int k=0;
	for(i=1;i<n;i++)
	{
		if(v[i].size()>v[k].size())
		k=i;
		else if(v[i].size()==v[k].size())
		{
			if
			(v[i][0]<v[k][0]) k=i;
		}
	}
printf("%d\n",k+1);
}


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

int main()
{
	int n,m,i,j,ma;
	cin>>n>>m;
	vector <int> v[n];
	ll arr[m][n];
	for(i=0;i<m;i++)
	for(j=0;j<n;j++)
	cin>>arr[i][j];
	for(i=0;i<m;i++)
	{
		ma=0;
		for(j=1;j<n;j++)
		{if(arr[i][j]>arr[i][ma])
		ma=j;
		}
	v[ma].push_back(i);
	}
	int k=0;
	for(i=1;i<n;i++)
	{	//if(v[i].size()==0) continue;
		if(v[i].size()>v[k].size())
		k=i;
		/*else if(v[i].size()==v[k].size())
		{
			if
			(v[i][0]<v[k][0]) k=i;
		}*/
	}
printf("%d\n",k+1);
}


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

int main()
{
	int n,m,i,j,ma;
	cin>>n>>m;
	vector <int> v[n];
	ll arr[m][n];
	for(i=0;i<m;i++)
	for(j=0;j<n;j++)
	cin>>arr[i][j];
	for(i=0;i<m;i++)
	{
		ma=0;
		for(j=1;j<n;j++)
		{if(arr[i][j]>arr[i][ma])
		ma=j;
		}
	v[ma].push_back(i);
	}
	int k=0;
	for(i=1;i<n;i++)
	{
		if(v[i].size()>v[k].size())
		k=i;
		else if(v[i].size()==v[k].size()&&v[i].size()!=0)
		{

			(v[i][0]<v[k][0]) k=i;
		}
	}
printf("%d\n",k+1);
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>

using namespace std;

struct point{
    int x;
    long long sum;
    bool operator  < (const point &b) const{
        if(sum == b.sum){
            return x < b.x;
        }
        return sum > b.sum;
    }
}p[505];

int main() {
    int n,m;
    cin >> n >> m;
    for(int i = 1;i<=m;i++){
        p[i].x = i;
        p[i].sum = 0;
    }
    for(int i = 0;i < m;i++){
        for(int j = 1;j <= n;j++){
            long long a;
            scanf("%I64d",&a);
            p[j].sum += a;
        }
    }
    sort(p,p+n);
    printf("%d\n",p[0].x);
    return  0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>

using namespace std;

struct point{
    int x;
    long long sum;
    bool operator  < (const point &b) const{
        if(sum == b.sum){
            return x < b.x;
        }
        return sum > b.sum;
    }
}p[505];

int main() {
    int n,m;
    cin >> n >> m;
    for(int i = 1;i<=n;i++){
        p[i].x = i;
        p[i].sum = 0;
    }
    for(int i = 0;i < m;i++){
        for(int j = 1;j <= n;j++){
            long long a;
            scanf("%I64d",&a);
            p[j].sum += a;
        }
    }
    sort(p,p+n);
    printf("%d\n",p[0].x);
    return  0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>

using namespace std;

int n;
struct point{
    int x;
    long long sum;
    bool operator  < (const point &b) const{
        if(sum == b.sum){
            return x < b.x;
        }
        return sum > b.sum;
    }
}p[105];

int main() {
    int n,m;
    cin >> m >> n;
    for(int i = 0;i<n;i++){
        for(int j = 0;j<m;j++){
            long long a;
            cin >> a;
            p[j].x = j;
            p[j].sum += a;
        }
    }
    sort(p,p+n);
    printf("%d\n",p[0].x+1);
    return  0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>

using namespace std;

int a[105][105];

int main() {
    int n,m;
    cin >> m >> n;
    for(int i = 0;i<n;i++){
        for(int j =0;j<m;j++){
            cin >> a[i][j];
        }
    }
    int c[105];
    memset(c,0,sizeof(c));

    for(int i = 0;i<n;i++){
            int tol = 0;
            int index = 0;
        for(int j = 0;j < m;j++){
            if(tol < a[i][j]){
                tol = a[i][j];
                index =j;
            }
        }
        c[index]++;
    }
    int index = 0;
    int tol = 0;
    for(int i =0;i<m;i++){
        if(tol < c[i]){
            tol = c[i];
            index = i;
        }
    }
    printf("%d\n",index+1);
    return  0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>

using namespace std;

struct point{
    int x;
    long long sum;
    bool operator  < (const point &b) const{
        if(sum == b.sum){
            return x < b.x;
        }
        return sum > b.sum;
    }
}p[105];

int main() {
    int n,m;
    cin >> m >> n;
    for(int i =0;i<m;i++){
        p[i].x = i;
        p[i].sum = 0;
    }
    for(int i = 0;i<n;i++){
        for(int j = 0;j<m;j++){
            long long a;
            scanf("%I64d",&a);
            p[j].sum += a;
        }
    }
    sort(p,p+n);
    printf("%d\n",p[0].x+1);
    return  0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>

using namespace std;

struct point{
    int x;
    long long sum;
    bool operator  < (const point &b) const{
        if(sum == b.sum){
            return x < b.x;
        }
        return sum > b.sum;
    }
}p[105];

int main() {
    int n,m;
    cin >> m >> n;
    for(int i = 0;i < n;i++){
        for(int j = 0;j<m;j++){
            long long a;
            scanf("%I64d",&a);
            p[j].x = j;
            p[j].sum += a;
        }
    }
    sort(p,p+m);
    printf("%d\n",p[0].x+1);
    return  0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>

using namespace std;

int a[105][105];

int main() {
    int n,m;
    cin >> m >> n;
    for(int i = 0;i<n;i++){
        for(int j =0;j<m;j++){
            cin >> a[i][j];
        }
    }
    int index = 0;
    int sum  =0;
    for(int j = 0;j < m;j++){
        int tol = 0;
        for(int i = 0;i < n;i++){
            tol = max(tol,a[i][j]);
        }
        if(tol > sum){
            sum = tol;
            index = j;
        }
    }
    printf("%d\n",index+1);
    return  0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>

using namespace std;

struct point {
    int x;
    long long sum;
    bool operator  < (const point &b) const {
        if(sum == b.sum) {
            return x < b.x;
        }
        return sum > b.sum;
    }
} p[505];

int main() {
    int n,m;
    cin >> m >> n;
    for(int i = 0; i < n; i++) {
        int ss = 0;
        long long tol = 0;
        for(int j = 0; j < m; j++) {
            long long a;
            scanf("%I64d",&a);
            if(tol < a) {
                tol = a;
                ss = j;
            }

        }
        p[ss].x = ss;
        p[ss].sum = max(tol,p[ss].sum);
    }
    sort(p,p+m);
    printf("%d\n",p[0].x+1);
    return  0;
}


#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
using namespace std;
int a[105][105];
int can[105]={0};
int main()
{
    int n, m;
    cin >> n >> m;
    for (int i=1; i<=m; i++)
        for (int j=1; j<=n; j++)
            cin >> a[i][j];

    for (int i=1; i<=m; i++)
    {
        int MAX=0;
        int MAX_ID=0;
        for (int j=1; j<=n; j++)
        {
            if (MAX<a[i][j])
            {
                MAX=a[i][j];
                MAX_ID=j;
            }
        }
        can[MAX_ID]++;
    }

    int MAX=-1, MAX_ID=-1;
    for (int i=1; i<=n; i++)
    {
        if (MAX<can[i])
        {
            MAX=can[i];
            MAX_ID=i;
        }
    }

    cout << MAX_ID << endl;
    return 0;
}


#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
using namespace std;
int a[105][105];
int can[105]={0};
int main()
{
    int n, m;
    cin >> n >> m;
    for (int i=1; i<=m; i++)
        for (int j=1; j<=n; j++)
            cin >> a[i][j];

    for (int i=1; i<=m; i++)
    {
        int MAX=0;
        int MAX_ID=0;
        for (int j=1; j<=n; j++)
        {
            if (MAX<a[i][j])
            {
                MAX=a[i][j];
                MAX_ID=j;
            }
        }
        can[MAX_ID]++;
    }

    int MAX=-1, MAX_ID=-1;
    for (int i=1; i<=m; i++)
    {
        if (MAX<can[i])
        {
            MAX=can[i];
            MAX_ID=i;
        }
    }

    cout << MAX_ID << endl;
    return 0;
}


#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
using namespace std;
int a[105][105];
int can[105]={0};
int main()
{
    int n, m;
    cin >> n >> m;
    for (int i=1; i<=n; i++)
        for (int j=1; j<=m; j++)
            cin >> a[i][j];

    for (int i=1; i<=n; i++)
    {
        int MAX=0;
        int MAX_ID=0;
        for (int j=1; j<=m; j++)
        {
            if (MAX<a[i][j])
            {
                MAX=a[i][j];
                MAX_ID=j;
            }
        }
        can[MAX_ID]++;
    }

    int MAX=-1, MAX_ID=-1;
    for (int i=1; i<=m; i++)
    {
        if (MAX<can[i])
        {
            MAX=can[i];
            MAX_ID=i;
        }
    }

    cout << MAX_ID << endl;
    return 0;
}


#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
using namespace std;
int a[105][105];
int can[105]={0};
int main()
{
    int n, m;
    cin >> n >> m;
    for (int i=1; i<=m; i++)
        for (int j=1; j<=n; j++)
            cin >> a[i][j];

    for (int i=1; i<=m; i++)
    {
        int MAX=-1;
        int MAX_ID=-1;
        for (int j=1; j<=n; j++)
        {
            if (MAX<a[i][j])
            {
                MAX=a[i][j];
                MAX_ID=j;
            }
        }
        can[MAX_ID]++;
    }

    int MAX=-1, MAX_ID=-1;
    for (int i=1; i<=n; i++)
    {
        if (MAX<can[i])
        {
            MAX=can[i];
            MAX_ID=i;
        }
    }

    cout << MAX_ID << endl;
    return 0;
}


#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
using namespace std;
int a[105][105];
int can[105]={0};
int main()
{
    int n, m;
    cin >> n >> m;
    for (int i=1; i<=n; i++)
        for (int j=1; j<=m; j++)
            cin >> a[i][j];

    for (int j=1; j<=m; j++)
    {
        int MAX=0, MAX_ID=0;
        for (int i=1; i<=n; i++)
        {
            if (MAX<a[i][j])
            {
                MAX=a[i][j];
                MAX_ID=i;
            }
        }
        can[MAX_ID]++;
    }

    int MAX=-1, MAX_ID=-10;
    for (int i=1; i<=n; i++)
    {
        if (MAX<can[i])
        {
            MAX=can[i];
            MAX_ID=i;
        }
    }

    cout << MAX_ID << endl;
    return 0;
}


#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
using namespace std;
int a[105][105];
int can[105]={0};
int main()
{
    int n, m;
    cin >> n >> m;
    for (int i=1; i<=n; i++)
        for (int j=1; j<=m; j++)
            cin >> a[i][j];

    for (int i=1; i<=n; i++)
    {
        int MAX=0;
        int MAX_ID=0;
        for (int j=1; j<=m; j++)
        {
            if (MAX<a[i][j])
            {
                MAX=a[i][j];
                MAX_ID=j;
            }
        }
        can[MAX_ID]++;
    }

    int MAX=-1, MAX_ID=-1;
    for (int i=1; i<=n; i++)
    {
        if (MAX<can[i])
        {
            MAX=can[i];
            MAX_ID=i;
        }
    }

    cout << MAX_ID << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int a[100][100];
int b[100];
int m,n;
void docinput()
{
    int tam,dem1,dem2;
    memset(b,0,sizeof(b));
    cin >> n >> m;
    for (int i = 1; i <= m; i++)
    {
        tam = -1;
        for (int j = 1;j <= n; j++)
        {
            cin >> a[i][j];
            if (tam < a[i][j])
            {
                tam = a[i][j];
                dem2 = j;
                dem1 = i;
            }
        }
        b[dem2] = b[dem2] +1;
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    //freopen("baia.inp", "r", stdin);
    //freopen("baia.out", "w", stdout);
    docinput();
    int cucdai,tam;
    cucdai = -1;tam = 1;
    for (int i = 1; i <= n; i++)
    {
        if (cucdai < b[i])
        {
            cucdai = b[i];
            tam = i;
        }
    }
    cout << tam;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int a[100][100];
int b[100];
int m,n;
void docinput()
{
    int tam,dem;
    memset(b,0,sizeof(b));
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    {
        tam = -1;
        for (int j = 1;j <= m; j++)
        {
            cin >> a[i][j];
            if (tam < a[i][j])
            {
                tam = a[i][j];
                dem = j;
            }
        }
        b[dem] = b[dem] + 1;
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    freopen("baia.inp", "r", stdin);
    freopen("baia.out", "w", stdout);
    docinput();
    int cucdai,tam;
    cucdai = b[1];tam = 1;
    for (int i = 2; i <= m; i++)
    {
        if (cucdai < b[i])
        {
            cucdai = b[i];
            tam = i;
        }
    }
    cout << tam;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int a[100][100];
int b[100];
int m,n;
void docinput()
{
    int tam,dem1,dem2;
    memset(b,0,sizeof(b));
    cin >> n >> m;
    for (int i = 1; i <= m; i++)
    {
        tam = -1;
        for (int j = 1;j <= n; j++)
        {
            cin >> a[i][j];
            if (tam < a[i][j])
            {
                tam = a[i][j];
                dem2 = j;
                dem1 = i;
            }
        }
        b[dem2] = b[dem2] +1;
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    freopen("baia.inp", "r", stdin);
    freopen("baia.out", "w", stdout);
    docinput();
    int cucdai,tam;
    cucdai = -1;tam = 1;
    for (int i = 1; i <= n; i++)
    {
        cout << b[i] << " ";
        if (cucdai < b[i])
        {
            cucdai = b[i];
            tam = i;
        }
    }
    cout << tam;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int a[100][100];
int b[100];
int m,n;
void docinput()
{
    int tam,dem1,dem2;
    memset(b,0,sizeof(b));
    cin >> n >> m;
    for (int i = 1; i <= m; i++)
    {
        tam = -1;
        for (int j = 1;j <= n; j++)
        {
            cin >> a[i][j];
            if (tam < a[i][j])
            {
                tam = a[i][j];
                dem2 = j;
                dem1 = i;
            }
        }
        b[dem2] = b[dem2] +1;
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    //freopen("baia.inp", "r", stdin);
    //freopen("baia.out", "w", stdout);
    docinput();
    int cucdai,tam;
    cucdai = -1;tam = 1;
    /*for (int i = 1; i <= n; i++)
    {
        cout << b[i] << " ";
        if (cucdai < b[i])
        {
            cucdai = b[i];
            tam = i;
        }
    }*/
    cout << tam;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int a[100][100];
int b[100];
int m,n;
void docinput()
{
    int tam,dem;
    memset(b,0,sizeof(b));
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    {
        tam = -1;
        for (int j = 1;j <= m; j++)
        {
            cin >> a[i][j];
            if (tam < a[i][j])
            {
                tam = a[i][j];
                dem = j;
            }
        }
        b[i] = b[dem] + 1;
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    //freopen("baia.inp", "r", stdin);
    //freopen("baia.out", "w", stdout);
    docinput();
    int cucdai,tam;
    cucdai = b[1];tam = 1;
    for (int i = 2; i <= n; i++)
    {
        if (cucdai < b[i])
        {
            cucdai = b[i];
            tam = i;
        }
    }
    cout << tam;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int a[100][100];
int b[100];
int m,n;
void docinput()
{
    int tam,dem;
    memset(b,0,sizeof(b));
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    {
        tam = -1;
        for (int j = 1;j <= m; j++)
        {
            cin >> a[i][j];
            if (tam < a[i][j])
            {
                tam = a[i][j];
                dem = j;
            }
        }
        b[dem] = b[dem] + 1;
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    //freopen("baia.inp", "r", stdin);
    //freopen("baia.out", "w", stdout);
    docinput();
    int cucdai,tam;
    cucdai = b[1];tam = 1;
    for (int i = 2; i <= m; i++)
    {
        if (cucdai < b[i])
        {
            cucdai = b[i];
            tam = i;
        }
    }
    cout << tam;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int a[200][200];
int b[200];
long long m,n;
void docinput()
{
    long long tam,dem1,dem2;
    memset(b,0,sizeof(b));
    cin >> n >> m;
    for (int i = 1; i <= m; i++)
    {
        tam = -1;
        for (int j = 1;j <= n; j++)
        {
            cin >> a[i][j];
            if (tam < a[i][j])
            {
                tam = a[i][j];
                dem2 = j;
                dem1 = i;
            }
        }
        b[dem2] = b[dem2] +1;
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    //freopen("baia.inp", "r", stdin);
    //freopen("baia.out", "w", stdout);
    docinput();
    long long cucdai,tam;
    cucdai = -1;tam = 1;
    for (int i = 1; i <= n; i++)
    {
        if (cucdai < b[i])
        {
            cucdai = b[i];
            tam = i;
        }
    }
    cout << tam;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int a[100][100];
int b[100];
int m,n;
void docinput()
{
    int tam,dem;
    memset(b,0,sizeof(b));
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    {
        tam = -1;
        for (int j = 1;j <= m; j++)
        {
            cin >> a[i][j];
            if (tam < a[i][j])
            {
                tam = a[i][j];
                dem = j;
            }
        }
        b[i] = b[dem] + 1;
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    freopen("baia.inp", "r", stdin);
    freopen("baia.out", "w", stdout);
    docinput();
    int cucdai,tam;
    cucdai = b[1];tam = 1;
    for (int i = 2; i <= m; i++)
    {
        if (cucdai < b[i])
        {
            cucdai = b[i];
            tam = i;
        }
    }
    cout << tam;
    return 0;
}


import java.util.*;

public class Grid_game {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
		boolean[][] arr = new boolean[4][4];
		String str = scan.next();
		scan.close();
		for (int i = 0; i < str.length(); i++) {
			boolean flag = false;
			if (str.charAt(i) == '1') {
				if (!arr[0][0]) {
					arr[0][0] = arr[0][1] = true;
				} else if (!arr[0][2]) {
					arr[0][2] = arr[0][3] = true;
				}
			} else {
				for (int j = 0; j < 3 && !flag; j++) {
					for (int t = 0; t < 4; t++) {
						if (!arr[j][t] && !arr[j + 1][t]) {
							arr[j][t] = arr[j + 1][t] = true;
							System.out.println(j + 1 + " " + (t + 1));
							flag = true;
							break;
						}
					}
				}
			}
			for (int k = 0; k < 4; k++) {
				if (arr[k][0] && arr[k][1] && arr[k][2] && arr[k][3]) {
					arr[k][0] = arr[k][1] = arr[k][2] = arr[k][3] = false;
				}
			}
			for (int k = 0; k < 4; k++) {
				if (arr[0][k] && arr[1][k] && arr[2][k] && arr[3][k]) {
					arr[0][k] = arr[1][k] = arr[2][k] = arr[3][k] = false;
				}
			}
		}
	}

}


import java.util.*;

public class Grid_game {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
		boolean[][] arr = new boolean[4][4];
		String str = scan.next();
		scan.close();
		for (int i = 0; i < str.length(); i++) {
			boolean flag = false;
			if (str.charAt(i) == '1') {
				for (int t = 0; t < 3 && !flag; t++) {
					for (int j = 0; j < 4; j++) {
						if (!arr[j][t] && !arr[j][t + 1]) {
							arr[j][t] = arr[j][t + 1] = true;
							System.out.println(j + 1 + " " + (t + 1));
							flag = true;
							break;
						}
					}
				}
			} else {
				for (int j = 0; j < 3 && !flag; j++) {
					for (int t = 0; t < 4; t++) {
						if (!arr[j][t] && !arr[j][t]) {
							arr[j][t] = arr[j + 1][t] = true;
							System.out.println(j + 1 + " " + (t + 1));
							flag = true;
							break;
						}
					}
				}
			}
			for (int k = 0; k < 4; k++) {
				if (arr[k][0] && arr[k][1] && arr[k][2] && arr[k][3]) {
					arr[k][0] = arr[k][1] = arr[k][2] = arr[k][3] = false;
				}
			}
		}
	}

}


import java.util.*;

public class Grid_game {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
		boolean[][] arr = new boolean[4][4];
		String str = scan.next();
		for (int i = 0; i < str.length(); i++) {
			boolean flag = false;
			if (str.charAt(i) == '1') {
				for (int j = 0; j < 4 && !flag; j++) {
					for (int t = 0; t < 4; t++) {
						if (!arr[j][t] && !arr[j][t + 1]) {
							arr[j][t] = arr[j][t + 1] = true;
							System.out.println(j + 1 + " " + (t + 1));
							flag = true;
							break;
						}
					}
				}
			} else {
				for (int j = 0; j < 4 && !flag; j++) {
					for (int t = 0; t < 4; t++) {
						if (!arr[j][t] && !arr[j][t]) {
							arr[j][t] = arr[j + 1][t] = true;
							System.out.println(j + 1 + " " + (t + 1));
							flag = true;
							break;
						}
					}
				}
			}
			for (int k = 0; k < 4; k++) {
				if (arr[k][0] && arr[k][1] && arr[k][2] && arr[k][3]) {
					arr[k][0] = arr[k][1] = arr[k][2] = arr[k][3] = false;
				}
			}
		}
	}

}


import java.util.*;

public class Grid_game {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
		boolean[][] arr = new boolean[4][4];
		String str = scan.next();
		scan.close();
		for (int i = 0; i < str.length(); i++) {
			boolean flag = false;
			if (str.charAt(i) == '1') {
				for (int t = 0; t < 3 && !flag; t++) {
					for (int j = 0; j < 4; j++) {
						if (!arr[j][t] && !arr[j][t + 1]) {
							arr[j][t] = arr[j][t + 1] = true;
							System.out.println(j + 1 + " " + (t + 1));
							flag = true;
							break;
						}
					}
				}
			} else {
				for (int j = 0; j < 3 && !flag; j++) {
					for (int t = 0; t < 4; t++) {
						if (!arr[j][t] && !arr[j + 1][t]) {
							arr[j][t] = arr[j + 1][t] = true;
							System.out.println(j + 1 + " " + (t + 1));
							flag = true;
							break;
						}
					}
				}
			}
			for (int k = 0; k < 4; k++) {
				if (arr[k][0] && arr[k][1] && arr[k][2] && arr[k][3]) {
					arr[k][0] = arr[k][1] = arr[k][2] = arr[k][3] = false;
				}
			}
			for (int k = 0; k < 4; k++) {
				if (arr[0][k] && arr[1][k] && arr[2][k] && arr[3][k]) {
					arr[0][k] = arr[1][k] = arr[2][k] = arr[3][k] = false;
				}
			}
		}
	}

}


import java.util.*;

public class Grid_game {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
		boolean[][] arr = new boolean[4][4];
		String str = scan.next();
		scan.close();
		for (int i = 0; i < str.length(); i++) {
			boolean flag = false;
			if (str.charAt(i) == '1') {
				if (!arr[0][0]) {
					arr[0][0] = arr[0][1] = true;
					System.out.println(1 + " " + (1));
				} else if (!arr[0][2]) {
					arr[0][2] = arr[0][3] = true;
					System.out.println(1 + " " + (3));
				}
			} else {
				for (int j = 0; j < 3 && !flag; j++) {
					for (int t = 0; t < 4; t++) {
						if (!arr[j][t] && !arr[j + 1][t]) {
							arr[j][t] = arr[j + 1][t] = true;
							System.out.println(j + 1 + " " + (t + 1));
							flag = true;
							break;
						}
					}
				}
			}
			for (int k = 0; k < 4; k++) {
				if (arr[k][0] && arr[k][1] && arr[k][2] && arr[k][3]) {
					arr[k][0] = arr[k][1] = arr[k][2] = arr[k][3] = false;
				}
			}
			for (int k = 0; k < 4; k++) {
				if (arr[0][k] && arr[1][k] && arr[2][k] && arr[3][k]) {
					arr[0][k] = arr[1][k] = arr[2][k] = arr[3][k] = false;
				}
			}
		}
	}

}


import java.util.*;

public class Grid_game {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
		boolean[][] arr = new boolean[4][4];
		String str = scan.next();
		scan.close();
		for (int i = 0; i < str.length(); i++) {
			boolean flag = false;
			if (str.charAt(i) == '1') {
				if (!arr[0][0]) {
					arr[0][0] = arr[0][1] = true;
					System.out.println(1 + " " + (1));
				} else if (!arr[0][2]) {
					arr[0][2] = arr[0][3] = true;
					System.out.println(1 + " " + (3));
				}
			} else {
				for (int j = 1; j < 3 && !flag; j++) {
					for (int t = 0; t < 4; t++) {
						if (!arr[j][t] && !arr[j + 1][t]) {
							arr[j][t] = arr[j + 1][t] = true;
							System.out.println(j + 1 + " " + (t + 1));
							flag = true;
							break;
						}
					}
				}
			}
			for (int k = 0; k < 4; k++) {
				if (arr[k][0] && arr[k][1] && arr[k][2] && arr[k][3]) {
					arr[k][0] = arr[k][1] = arr[k][2] = arr[k][3] = false;
				}
			}
			for (int k = 0; k < 4; k++) {
				if (arr[0][k] && arr[1][k] && arr[2][k] && arr[3][k]) {
					arr[0][k] = arr[1][k] = arr[2][k] = arr[3][k] = false;
				}
			}
		}
	}

}


import java.util.Scanner;
import java.util.Stack;

public class CodeChef {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s=sc.next();
        int v=0,h=0;
        for (int i=0;i<s.length();i++) {
            if (s.charAt(i) == '0') {
                System.out.println("2 " + (v + 1));
                v = (v + 1) % 4;
            } else {
                System.out.println("1 " + (h + 1));
                h = (h + 2) % 4;
            }
        }
    }
}


//package home;
import java.util.*;
public class Main{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int i,t=0,k=0,j=0;
       String  s=sc.nextLine();
       String a[]=new String [4];
       a[0]="2 1";
       a[1]="2 2";
       a[2]="2 3";
       a[3]="2 4";
       String b[]=new String [2];
       b[0]="1 1";
       b[1]="1 3";
       //char c[]=new char[s.length()+1];
          for(i=0,k=0;i<s.length();i++){
          if(s.charAt(i)=='0'){
            System.out.println(a[j]);
            j++;
            if(j==4)
            j=0;
          }
          else{
            System.out.println(b[k]);
            k++;
            if(k==2)
            k=0;
          }

          }
    }
}


//package home;
import java.util.*;
public class Main{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int i,t=0,k=0,j=0;
       String  s=sc.nextLine();
       String a[]=new String [4];
       a[0]="2 1";
       a[1]="2 2";
       a[2]="2 3";
       a[3]="2 4";
       String b[]=new String [2];
       b[0]="1 1";
       b[1]="1 3";
       //char c[]=new char[s.length()+1];
          for(i=0,k=0;i<s.length();i++){
          if(s.charAt(i)=='1'){
            System.out.println(a[j]);
            j++;
            if(j==4)
            j=0;
          }
          else{
            System.out.println(b[k]);
            k++;
            if(k==2)
            k=0;
          }

          }
    }
}


import java.io.*;
import java.util.StringTokenizer;

public class SolverC {

    StringTokenizer stok;
    BufferedReader br;
    PrintWriter pw;

    String nextToken() throws IOException {
        while (stok == null || !stok.hasMoreTokens()) {
            stok = new StringTokenizer(br.readLine());
        }
        return stok.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    private void run() throws IOException {
//        br = new BufferedReader(new FileReader("input.txt"));
//        pw = new PrintWriter("output.txt");
        br = new BufferedReader(new InputStreamReader(System.in));
        pw = new PrintWriter(new OutputStreamWriter(System.out));
        solve();
        pw.flush();
        pw.close();
    }

    public static void main(String[] args) throws IOException {
        new SolverC().run();
    }

    private void solve() throws IOException {
        String str = nextToken();
        int len = str.length();
        int count0 = 0;
        int count1 = 0;
        for (int i=0; i<len; i++) {
            if (str.charAt(i) == '0') {
                count0 = (count0 + 1) % 4;
                pw.println("1 " + (count0 + 1));
            } else {
                count1 = (count1 + 2) % 4;
                pw.println("3 " + (count1 + 1));
            }
        }
    }
}