#include<bits/stdc++.h>
using namespace std;

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

struct segmentTree{

    int N;
    vector< pair<int, int> > node;
    const int INF = -1;
    
    void init(int siz){
        N = 1;
        while(N < siz){
            N <<= 1;
        }
        node.resize(N * 2 - 1, {INF, -1});
    }

    void build(vector<int> &dat){
        for(int i = 0, len = dat.size() ; i < len ; ++i){
            node[i + N - 1] = {dat[i], -i};
        }
        for(int i = N - 2 ; i >= 0 ; --i){
            node[i] = min(node[i * 2 + 1], node[i * 2 + 2]);
        }
    }

    void update(int k, int x){
        k += N - 1;
        node[k].first = x;
        while(k > 0){
            k = (k - 1) / 2;
            node[k] = max(node[k * 2 + 1], node[k * 2 + 2]);
        }
    }

    pair<int, int> getMax(int a, int b, int k, int l, int r){
        if(r <= a || b <= l){
            return {INF, -1};
        }
        if(a <= l && r <= b){
            return node[k];
        }
        pair<int, int> vl = getMax(a, b, k * 2 + 1, l, (l + r) / 2);
        pair<int, int> vr = getMax(a, b, k * 2 + 2, (l + r) / 2, r);
        return max(vl, vr);
    }

    pair<int, int> getMax(int a, int b){
        return getMax(a, b, 0, 0, N);
    }

};

int main(){
    int n, q;
    cin >> n >> q;
    vector<int> v(n, 0);
    segmentTree st;
    st.init(n);
    st.build(v);
    rep(i, q){
        int a, x;
        cin >> a >> x;
        --a;
        v[a] += x;
        st.update(a, v[a]);
        P ans = st.getMax(0, n);
        cout << -ans.second + 1 << " " << ans.first << endl;
    }
    return 0;
}
