#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int,int> P;
typedef std::pair<int,P> State;

const int INF = 1001001001;

// S N E W(南北東西)
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

const int MAX_N = 1000000;

class SegmentTree{
public:
    SegmentTree(){}
    SegmentTree(int n){init(n);}
    void init(int n){
        size = 1;
        while(size < n){
            size *= 2;
        }
        
        REP(i, size){
            update(i, 0);
        }
    }
    void update(int k, int v){
        k += size - 1;
        seg1[k] = v;
        seg2[k] = k - (size-1);
        
        while(k > 0){
            k = (k-1) / 2;
            if(seg1[k*2+1] > seg1[k*2+2]){
                seg1[k] = seg1[k*2+1];
                seg2[k] = seg2[k*2+1];
            }else{
                seg1[k] = seg1[k*2+2];
                seg2[k] = seg2[k*2+2];
            }
        }
    }
    P query(int l, int r){
        return _query(l, r, 0, 0, size);
    }
private:
    P _query(int a, int b, int k, int l, int r){
        if(b <= l || r <= a){return mp(0, -1);}
        if(a <= l && r <= b){return mp(seg1[k], seg2[k]);}
        P lp = _query(a, b, 2*k+1, l, (l+r)/2), rp = _query(a, b, 2*k+2, (l+r)/2, r);
        if(lp.first >= rp.first){
            return lp;
        }else{
            return rp;
        }
    }
    int seg1[MAX_N*4], seg2[MAX_N*4], size;
};

int N, Q;
SegmentTree st;

int main(){
    std::cin >> N >> Q;
    st.init(N);
    
    REP(i, Q){
        int a, v;
        std::cin >> a >> v;
        --a;
        int nv = st.query(a, a+1).first + v;
        st.update(a, nv);
        P res = st.query(0, N);
        std::cout << res.second+1 << " " << res.first << std::endl;
    }
}