#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


class SegTree{
private:
    int n;
    vector<pii> seg;
    pii init = pii(0,INF); //初期化の値（単位元）
    pii combine(pii a, pii b){
        if(a.first == b.first && a.second < b.second)return a;
        if(a.first > b.first)return a;
        return b;
    }
public:
    SegTree (){}
    SegTree(const vi &in){
        n=1;
        while(n<in.size())n<<=1;
        seg=vector<pii>(2*n,init);
        for(int i=n-1+in.size()-1;i>=0;i--){
            if(n-1<=i)seg[i]=pii(in[i-(n-1)],i-(n-1));
            else seg[i]=combine(seg[i*2+1],seg[i*2+2]);
        }
    }

    void update(int k,int a){
        k+=n-1;
        seg[k].first = a;
        while(k>0){
            k=(k-1)/2;
            seg[k]=combine(seg[k*2+1],seg[k*2+2]);
        }
    }

    //[a,b)について調べる
    pii query(int a,int b,int k=0,int l=0,int r=-1){
        if(r==-1)r=n;
        if(r<=a || b<=l)return init;
        if(a<=l &&r<=b)return seg[k];
        pii vl=query(a,b,k*2+1,l,(l+r)/2);
        pii vr=query(a,b,k*2+2,(l+r)/2,r);
        return combine(vl,vr);
    }

    void show(){
        rep(i,n)cout << " " << seg[i+n-1].first;
        cout << endl;
    }

};

signed main(void) {
    int n,q;
    cin >> n >> q;
    vi v(n);
    SegTree st(v);
    while(q--){
        int a,b;
        cin >> a >> b;
        a--;
        pii t = st.query(a, a+1);
        st.update(a, t.first + b);
        //st.show();
        pii ans = st.query(0,n);
        cout << ans.second + 1 << " " << ans.first << endl;
    }
}

