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

struct P{
    int first;
    int second;
    P(int a,int b) : first(a), second(b) {}
    bool operator<( const P& o ) const {
        return second == o.second ? first > o.first : second < o.second;
    }
};

P genP(int a, int b){
    P res(a, b);
    return res;
}

int main(){
    int n, q, m_a = 0;
    cin >> n >> q;
    priority_queue< P > pq;
    vector<int> nl(n+1, 0);
    for(int i = 1; i <= n; i++){
        pq.push( genP(i, 0) );
    }
    for(int i = 0; i < q; i++){
        int a, v;
        cin >> a >> v;
        nl[a] += v;
        pq.push( genP(a, nl[a]) );
        while( nl[ pq.top().first ] != pq.top().second ){
            pq.pop();
        }
        P tp = pq.top();
        cout << tp.first << ' ' << tp.second << endl;
    }
    return 0;
}