#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
typedef pair<ll,ll> LLP;
//#define INF 1000000007
#define ARRAY_MAX 100005
const ll INF = 1e17;

struct SegmentTree{

    int N;
    vector<P> node;
    const int INF = INT_MAX;

    void init(int siz){
        N = 1;
        while(N < siz){
            N *= 2;
        }
        node.resize(2*N-1);
        for(int i = 0;i < N;i++){
            node[i+N-1] = {0,-(i+1)};//釣った数と釣った人の番号
        }
        for(int i = N-2;i >= 0;i--){
            node[i] = max(node[2*i+1],node[2*i+2]);
        }
    }

    /*void build(vector<int>& dat){
        for(int i = 0;i < dat.size();i++){
            node[i+N-1] = dat[i];
        }
        for(int i = N-2;i >= 0;i--){
            node[i] = min(node[2*i+1],node[2*i]+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[2*k+1],node[2*k+2]);
        }
    }

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

    P getMax(int a,int b){
        return getMax(a,b,0,0,N);
    }
};

int main(){

    SegmentTree segt;
    int n,q;
    cin >> n >> q;
    segt.init(n);
    REP(i,q){
        int x,y;
        cin >> x >> y;
        segt.update(x-1,y);
        P ans = segt.getMax(0,n);
        cout << abs(ans.second) << " " << ans.first << endl;
    }



    return 0;
}
