#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iomanip>

using namespace std;

int n,q,a,v;



int main(){
    
        
    while(cin >> n >> q){
        int wakasagi[1000001]={0};
        int outnum=1;
        int outwakasagi=0;

        for(int i=0; i<q; i++){
            cin>>a>>v;
            wakasagi[a]+=v;
            
            if(v<0&&a==outnum){
                outwakasagi+=v;
                for(int i=1; i<=n; i++){
                    if(outwakasagi<wakasagi[i]){
                        outwakasagi=wakasagi[i];
                        outnum=i;
                    }else if(outwakasagi==wakasagi[i]&&outnum>i){
                        outwakasagi=wakasagi[i];
                        outnum=i;
                    }
                }
            }else if(wakasagi[a]>outwakasagi){
                outnum=a;
                outwakasagi=wakasagi[a];
            }else if(wakasagi[a]==outwakasagi&&a<outnum){
                outnum=a;
            }
            cout<<outnum<<" "<<outwakasagi<<endl;
        }
    }
            
}