#include <cstdio>
#include <queue>
#include <utility>

using namespace std;

const int m = 100000000;

priority_queue< pair< int, int > > Q;
int d[m], n, s, x[m], y[m];

int main()
{
    scanf( "%d %d\n", &n, &s );
    Q.push( make_pair( 0, -1000000000 ) );
    for( int i = 0; i < s; i++ )
    {
        scanf( "%d %d\n", &x[i], &y[i] );
        d[x[i]] += y[i];
        Q.push( make_pair( d[x[i]], -x[i] ) );
        while( 1 )
        {
            pair< int, int > p = Q.top();
            if( p.first == d[-p.second] )
            {
                printf( "%d %d\n", -p.second, p.first );
                break;
            }
            Q.pop();
        }
    }
    return 0;
}
