#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int need(int n)
{
	n--;
	for(int i=1;i<=16;i*=2)
		n|=n>>i;
	return 1<<__builtin_popcount(n);
}

int main()
{
	for(int n,q;~scanf("%d%d",&n,&q) && n|q;){
		n=need(n);
		vi value(n),index(2*n);
		rep(i,n) index[n+i]=i;
		for(int i=n;--i;) index[i]=index[i*2];
		rep(_,q){
			int a,v; scanf("%d%d",&a,&v); a--;
			value[a]+=v;
			for(int i=(n+a)/2;i;i/=2){
				if(value[index[i*2]]>=value[index[i*2+1]])
					index[i]=index[i*2];
				else
					index[i]=index[i*2+1];
			}
			printf("%d %d\n",index[1]+1,value[index[1]]);
		}
	}
	
	return 0;
}