#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( n + 2, Data() );
		for( int i = 1; i <= n; ++i ){
			p[ i ].id = i;
			p[ i ].prev = &p[ i - 1 ];
			p[ i ].next = &p[ i + 1 ];
		}
		p[ 1 ].prev = p[ n ].next = NULL; 
		total[ 0 ] = &p[ 1 ];

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

	return 0;
}