#include<iostream>
#include<map>
#include<algorithm>
using namespace std;
int main()
{
    int n, q, a, v;
    map<int, int> m;
    map<int,int>::iterator first, largest;
    for(cin>>n>>q; cin>>a>>v;) {
        m[a] += v;
        for(first = largest = m.begin(); ++first != m.end();) if(largest->second < first->second) largest = first;
        cout<<largest->first<<" "<<largest->second<<endl;
    }
}