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

int possessionfish[1000001];

int main(void){
    int n,event;
    cin>>n>>event;
    
    int human_num,fishing;
    cin>>human_num>>fishing;
    cout<<human_num<<" "<<fishing<<endl;
    
    possessionfish[human_num]+=fishing;
    int top_num = human_num;
    
    for(event = event - 1;event>0;event--){
        cin>>human_num>>fishing;
        possessionfish[human_num]+=fishing;
        
        if(fishing > 0){
            if(possessionfish[human_num] > possessionfish[top_num] || possessionfish[top_num]==possessionfish[human_num]&& human_num < top_num){
                top_num = human_num;
                cout<<human_num<<" "<<possessionfish[human_num]<<endl;
            }else{
                cout<<top_num<<" "<<possessionfish[top_num]<<endl;
            }
        }
        else{
            if(top_num == human_num){
                for(int i=1;i<=n;i++){
                    if(possessionfish[i] > possessionfish[top_num]){
                        top_num = i;
                        cout<<i<<" "<<possessionfish[i]<<endl;
                        break;
                    }
                    if(i == n)cout<<top_num<<" "<<possessionfish[top_num]<<endl;
                }
            }else{
                cout<<top_num<<" "<<possessionfish[top_num]<<endl;
            }
        }
    }
    
}

