#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
#define MAX(a,b) a > b ? a : b

typedef long long int ll;

using namespace std;
pair<int,int> tree[3000001];
int n,q;

pair<int,int> pmax(pair<int,int> a,pair<int,int> b){
    pair<int,int> ret = MAX(a,b);
    if(a.first == b.first){
	ret.second = min(a.second,b.second);
    }
    return ret;
}

void init(int k,int l,int r){
    if (r-l==1) tree[k] = tree[l];
    else{
	int chl = 2 * k + 1,chr = 2 * k + 2;
	int m = (int)( (l+r) / 2);
	init(chl,l,m);
	init(chr,m,r);
	tree[k] = pmax(tree[chl],tree[chr]);
    }
}

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


int main(){
    //pair<int,int> ma(-100000000,-1);
    cin >> n >> q;
    REP(i,2*n) tree[n+i] = pair<int,int>(0,0);
    REP(i,n){
    	tree[n+i].second = i + 1;
    }
    vector< pair<int,int> > ar(n);
    vector<bool> u(q,false);
    REP(i,q){
	int a,v;
	cin >> a >> v;
	update(a-1,v);
	cout << tree[0].second << " " << tree[0].first << endl;
    }
    return 0;
}