#include <bits/stdc++.h>
#define range(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define rep(i,n) range(i,0,n)
using namespace std;

int n,q;
int a[100010];
typedef tuple<int,int> state;
set<state> s;

int main(void){
	cin >> n >> q;
	rep(i,n) s.insert(state(0,i)),a[i]=0;
	rep(i,q){
		int w,v;
		cin >> w >> v;
		w--;
		auto it=s.find(state(-a[w],w));
		s.erase(it);
		a[w]+=v;
		s.insert(state(-a[w],w));
		int res[2];
		tie(res[1],res[0])=*(s.begin());
		cout << res[0]+1 << " " << -res[1] << endl;
	}
	return 0;
}