#include <iostream>
#include <vector>
#include <set>
#include <tuple>
#include <functional>
using namespace std;
int main() {
    int n, q;
    while (cin >> n >> q) {
        set<tuple<int, int>> players;
        vector<int> memo(n, 0);
        for (int i = 0; i < q; i++) {
            int a, v;
            cin >> a >> v;
            a--;
            players.erase(make_tuple(-memo[a], a));
            memo[a] += v;
            players.insert(make_tuple(-memo[a], a));
            cout << get<1>(*players.begin()) + 1 << ' ' << -get<0>(*players.begin()) << endl;
        }
    }
    return 0;
}