#include<algorithm>
#include<iostream>
#include<utility>
#include<climits>

typedef std::pair<int, int> P;

const int ST_SIZE = 1 << 21;
int sz;
P dat[ST_SIZE];

void init( int n )
{
	sz = 1;
	while( sz < n )
		sz *= 2;

	for( int i = 0; i != 2 * sz - 1; ++i )
		dat[i] = P( 0, 0 );

	return;
}

void add( int k, int a )
{
	k += sz - 1;
	dat[k].first += a;

	while( k > 0 )
	{
		k = ( k - 1 ) / 2;
		dat[k] = std::max( dat[k * 2 + 1], dat[k * 2 + 2] );
	}

	return;
}

P query( int a, int b, int k, int l, int r )
{
	if( r <= a || b <= l )
		return P( INT_MIN, INT_MIN );

	if( a <= l && r <= b )
		return dat[k];
	
	P vl = query( a, b, k * 2 + 1, l, ( l + r ) / 2 ),
	  vr = query( a, b, k * 2 + 2, ( l + r ) / 2, r );

	return std::max( vl, vr );
}

int main()
{
	int n, q;
	std::cin >> n >> q;

	init( n );

	for( int i = 0; i != n; ++i )
		dat[i+sz-1].second = -i;

	for( int i = 0; i != q; ++i )
	{
		int a, v;
		std::cin >> a >> v;

		P p = query( a - 1, a, 0, 0, n );
		add( a - 1, v );

		p = query( 0, n, 0, 0, n );

		std::cout << -p.second + 1 << " " << p.first << std::endl;
	}

	return 0;
}