#include<iostream>
#include<algorithm>
using namespace std;
struct segtree{
    int bin;
    int sum[3000010];
    int idx[3000010];
    void init(int a){
        for(int i=0;i<2*a;i++){
            sum[i] = -1000;
            idx[i] = 1;
        }
        bin = 1;
        while(bin < a) bin *= 2;
        for(int i=0;i<a;i++){
            sum[i+bin-1] = 0;
            idx[i+bin-1] = i+1;
        }
    }
    
    void add(int a,int v){
        int now = a+bin-1;
        sum[now] += v;
        while(now > 0){
            now = (now-1)/2;
            if(sum[2*now+1] < sum[2*now+2]){
                sum[now] = sum[2*now+2];
                idx[now] = idx[2*now+2];
            } else {
                sum[now] = sum[2*now+1];
                idx[now] = idx[2*now+1];
            }
        }
    }
    int max(){
        return sum[0];
    }
    
    int maxidx(){
        return idx[0];
    }
    
};
segtree seg;
int main()
{
    int n,q,a,v;
    cin >> n >> q;
    seg.init(n);
    for(int i=0;i<q;i++){
        cin >> a >> v;
        seg.add(a-1,v);
        cout << seg.maxidx() << " " << seg.max() << endl;
    }
    return 0;
}

