#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

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

    vector<int> x(n+1, 0);
    priority_queue<pair<int, int> > pq;

    for(int i=0; i<q; ++i){
        int a, v;
        cin >> a >> v;
        x[a] += v;
        pq.push(make_pair(x[a], -a));

        for(;;){
            int b = -pq.top().second;
            int w = pq.top().first;
            if(x[b] == w){
                cout << b << ' ' << w << endl;
                break;
            }
            pq.pop();
        }
    }

    return 0;
}