#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

struct Data
{
	Data() : id( 0 ), cnt( 0 ), prev( NULL ), next( NULL ){}
	int id;
	int cnt;
	Data* prev;
	Data* next;
};

int main()
{
	int n, q;
	while( cin >> n >> q ){
		vector< Data* > total( 100 * q + 1, NULL );
		vector< Data > p( 100000, Data() );
		vector< Data* > acc( n + 1, NULL );
		int sec = 0;
		acc[ 1 ]  = &p[ sec ];
		p[ sec ].id = 1;
		++sec;
		total[ 0 ] = acc[ 1 ];

		int high = 0;
		for( int i = 0; i < q; ++i ){
			int a, v;
			cin >> a >> v;
			if( acc[ a ] == NULL ){
				acc[ a ] = &p[ sec ];
				acc[ a ]->id = a;
				++sec;
			}
			Data* b = acc[ a ];
			if( total[ b->cnt ] == b ){
				total[ b->cnt ] = b->next;
			} 
			b->cnt += v;
			Data* pp = b->prev;
			Data* pn = b->next;
			if( pp != NULL ) pp->next = pn;
			if( pn != NULL ) pn->prev = pp;
			b->prev = b->next = NULL;
			Data* s = total[ b->cnt ];
			if( s == NULL ){
				total[ b->cnt ] = b;
			}else{
				while( s->next != NULL && s->id < b->id ) s = s->next;
				if( s->id < b->id ){
					s->next = b;
					b->prev = s;
				}else{
					b->next = s;
					b->prev = s->prev;
					s->prev = b;
					if( b->prev == NULL ){
						total[ b->cnt ] = b;
					}
				}
			}
			if( v > 0 ){
				high = max( high, b->cnt );
			}else{
				while( total[ high ] == NULL ) --high;
			}
			cout << total[ high ]->id << " " << total[ high ]->cnt << endl;
		}
	}

	return 0;
}