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

