#include <bits/stdc++.h>

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;

// .init(??°)??§?????????, .update(???????????°???)??§?????????????????????
// .query(a,b)??§??????[a,b)??§????°???????????????????
// ?????§???????????´???????????? comp???min->max ??¨ INF=-1LL*1LL<<61
struct Segtree{
	typedef int sgT;
	vector<sgT> seg;
	int nbn; sgT INF;
	void init(int n){
		for(nbn=1; nbn<n+2; nbn<<=1); INF= 0; // min:+inf,max:-inf
		seg.assign(nbn*2, INF);
	}
	sgT comp(sgT l, sgT r){return max(l, r);}  //min<->max
	void update(int k,sgT x){
		k+=nbn-1; seg[k]=x;
		while(k>0){ k=(k-1)/2; seg[k]=comp(seg[k*2+1],seg[k*2+2]); }
	}
	sgT query2(int a,int b,int l,int r,int k){
		if(b<=l||r<=a) return INF;
		if(a<=l&&r<=b) return seg[k];
		return comp(query2(a,b,l,(l+r)/2,k*2+1), query2(a,b,(l+r)/2,r,k*2+2));
	}
	sgT query(int a,int b){ return query2(a,b,0,nbn,0); }
	sgT get(int a){return seg[nbn+a-1];}  // =query(a,a+1)
};


int main()
{
	
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n,q;
	cin >>n >>q;
	Segtree sga;
	sga.init(n+5);
	rep(i,q){
		int a,v;
		cin >>a >>v;
		int w = sga.get(a);
		sga.update(a, w +v);
		int lo=0, hi=n+1;
		int qk = sga.query(lo, hi);
		while(hi - lo >1){
			int md = (hi + lo) >> 1;
			if( sga.query(lo, md) >= qk ) hi = md; else lo = md; 
		}
		cout << lo  <<" "<< qk <<"\n";
		//rep(i,n+3) printf("%d:%d ",i,sga.query(i,i+1));puts("");

	}
	
	return 0;
}