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

typedef pair<int,int> P;
class sta{
public:
    bool operator()(const P& left,const P& right)const{
        if(left.second == right.second) return left.first < right.first;
        return left.second > right.second;
    }
};

int main(){
    int n,q,fig,value;
    cin >> n >> q;
    vector <P> ans(n+1);
    vector <int> fish(n+1);
    fill(fish.begin(),fish.end(),0);
    for(int i=0;i<q;i++){
        cin >> fig >> value;
        fish[fig] += value;
        for(int i=0;i<=n;i++){
            ans[i].first = 0; ans[i].second = 0;
        }
        for(int i=1;i<=n;i++) ans.push_back(P(i,fish[i]));
        sort(ans.begin(),ans.end(),sta());
        cout << ans[0].first << " " << ans[0].second << endl;
    }
}