#include <iostream>
#include <vector>
#include <queue>
#include <map>
using namespace std;

int main(){
    int n,q,fig,value;
    cin >> n >> q;
    vector <int> memo(n+1);
    fill(memo.begin(),memo.end(),0);
    priority_queue<pair<int,int> > que;
    que.push(make_pair(0,-1));
    while(q--){
        cin >> fig >> value;
        memo[fig] += value;
        for(int i=1;i<=n;i++) que.push(make_pair(memo[i],-i));
        for(;;){
            if(que.top().first == memo[-que.top().second]){
                cout << -que.top().second << " " << que.top().first << endl;
                break;
            }
            que.pop();
        }
    }
}