//J3で１番プログラミングと数学ができない奴のテストプログラム
//aoj0099
#include<iostream>
#include<vector>
#include<algorithm>
#define rep(i,n) for(i = 0;i < n;i++)
#define F first
#define S second
using namespace std;
typedef pair<int,int> P;

class segtree{
	P *a;		//MAX_NUM,MAX_CNT
	int dep;	//Length from root to leaf
public:
	segtree(int depth,int x = 0){
		int i;
		int size = (1 << (depth+1))-1;
		a = new P[size];
		rep(i,size)
			a[i] = P(1,x);
	}
	~segtree(){
		delete[] a;
	}
	void add(int i,int x)
	{
		int index = (1 << dep)-1+i;
		int incnt = a[index].S + x;
		a[index] = P(index,incnt);
		while( index >= 0 )
		{
			if( (a[index].S < incnt) || (a[index].S == incnt && a[index].F > i) )
				a[index] = P( i,incnt );
			index = (index-1) >> 1; 
		}
	}
	P getmax(int i,int j)
	{
		if(i > j)
			swap(i,j);
		int index_l = (1 << dep)-1+i;
		int index_r = (1 << dep)-1+j;
		P ans;
	
		while( index_l < index_r )
		{
			if( (a[index_l].S >= a[index_r].S) )
				ans = a[index_l];
			else
				ans = a[index_r];
			index_l = ( (index_l-1) >> 1) +1;
			index_r = ( (index_r-1) >> 1) -1;
		}
		return ans;
	}
};

int main(){
	segtree seg(20);
	int n,q,a,b;
	int i;
	cin >> n >> q;
	rep(i,q)
	{
		cin >> a >> b;
		seg.add( a,b );
		cout << seg.getmax(1,n).F << " " << seg.getmax(1,n).S << endl;
	}
	return 0;
}