#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999



template<class T>
class segtree{
private:
    vector<T> dat;
    int _size;  //the number of leaves
    T _init;
    
public:
    segtree(int __size=0 , T init=numeric_limits<T>::max() ):_size(__size) , _init(init) , dat(4*__size,init){
        if(__size==0)return ;
        int x=1;
        while(x<_size)x*=2;
        _size = x;
    }
    
    void update(int m,T x){
        int i = m+_size;
        dat[i].second = x.second;
        dat[i].first += x.first;
        while(i!=1){
            dat[i/2] = max(dat[i],dat[i^1]);
            i/=2;
        }
    }
    
    // call find(s,t)
    T find(int s,int t,int num=1,int a=0,int b=-1){
        if(b==-1)b=_size-1; //I couldn't "int b=_size".
//        if(b<s||t<a)return _init;
        if(s<=a&&b<=t)return dat[num];
        return max( find(s,t,num*2,a,(a+b)/2) , find(s,t,num*2+1,(a+b)/2+1,b) );
    }
    int size(){return _size;}
};

int main(){
    int n,q;
    cin>>n>>q;
    segtree<pii> st(n,pii(0,0));     //100 datas
    rep(i,n){
        st.update(i,pii(0,i));
    }
    rep(i,q){
        int a,v;
        cin>>a>>v;
        a--;
        st.update(a,pii(v,a));
        cout<<st.find(0,n).second+1<<" "<<st.find(0,n).first<<endl;
    }
    
}