#include <iostream>
#include <cstdio>
#include <queue>
#include <map>

#define reep(i,n,m) for(int i=(n);i<(m);i++)
#define rep(i,n) reep(i,0,n)

using namespace std;

typedef pair<int,int> pii;

int v[1000000+1];

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

    priority_queue<pii> Q;
    while(q--){
        int ai,vi;
        scanf("%d %d",&ai,&vi);
        v[ai] += vi;
        Q.push(pii(v[ai],-ai));
        while(1){
            pii p = Q.top();
            if(v[-p.second] == p.first){
                printf("%d %d\n",-p.second, p.first);
                break;
            }
            Q.pop();
        }
    }
    return 0;
}