#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,event;
    cin>>n>>event;
    
    vector<int> possessionfish(n+1, 0);
    vector<int>::iterator iter;
    
    int index, topNum = -1;
    int fishing,num;
    
    for(;event>0;--event){
        cin>>num>>fishing;
        possessionfish[num]+=fishing;
        
        if(topNum == -1)topNum = num;
        else if(fishing > 0){
            if(possessionfish[num] > possessionfish[topNum] || (topNum > num && possessionfish[num] == possessionfish[topNum]))topNum = num;
        }else if(topNum == num){
            iter = max_element(possessionfish.begin(), possessionfish.end());
            index = distance(possessionfish.begin(), iter);
            topNum = index;
        }
        
        cout<<topNum<<" "<<possessionfish[topNum]<<endl;
    }
}

