#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,ivent,cheman,chefish,topman=0,topfish=0;
    cin>>n>>ivent;
    int fish[n+1];
    for(int i=1;i<=n;i++)fish[i]=0;
    for(int i=0;i<ivent;i++){
        cin>>cheman>>chefish;
        fish[cheman]+=chefish;
        if(topfish<fish[cheman]){
            topman=cheman;
            topfish=fish[cheman];
        }
        else if(cheman==topman){
            topfish=fish[cheman];
            for(int j=1;j<=n;j++){
                if(topfish<fish[j]){
                    topman=j;
                    topfish=fish[j];
                }
            }
        }
        for(int j=1;j<topman;j++){
                if(fish[j]==topfish){
                        topman=j;
                        break;
                    }
            }

        cout<<topman<<" "<<topfish<<endl;
    }
}