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

struct Data
{
	int id;
	int cnt;
};

class RANKING
{
public:
	bool operator()( Data* a, Data* b )
	{
		return ( a->cnt > b->cnt || ( a->cnt == b->cnt && a->id < b->id ) );
	}
};

int main()
{
	int n, q;
	while( cin >> n >> q ){
		Data* d = new Data[ n ]; 
		vector< Data* > rank( n, NULL );

		for( int i = 0; i < n; ++i ){
			d[ i ].id = i + 1;
			d[ i ].cnt = 0;
			rank[ i ] = &d[ i ];
		}

		for( int i = 0; i < q; ++i ){
			int a, v;
			cin >> a >> v;
			d[ a - 1 ].cnt += v;
			sort( rank.begin(), rank.end(), RANKING() );
			cout << rank[ 0 ]->id << " " << rank[ 0 ]->cnt << endl;
		}

		delete[] d;
	}

	return 0;
}