#include <cstdio>
#include <map>

using namespace std;

struct SegTree {
    // root: vs[1]
    int *vs;
    int n;
    SegTree(int _n) {
        n = 1;
        while (n < _n) n *= 2;
        vs = new int[2 * n];
    }
    void add(int index, int v) {
        index += n;
        vs[index] += v;
        while (index > 0) {
            index /= 2;
            vs[index] = max(vs[index*2], vs[index*2+1]);
        }
    }
    pair<int, int> maximum() {
        int i = 1;
        while (i < n) {
            if (vs[i] == vs[i*2]) {
                i = i * 2;
            } else {
                i = i * 2 + 1;
            }
        }
        return make_pair(i - n, vs[1]);
    }
    ~SegTree() {
        delete[] vs;
    }
};

int main() {
    int n, q;
    scanf("%d %d", &n, &q);
    SegTree segt(n+1);
    for (int i = 0; i < q; i++) {
        int a, v; scanf("%d %d", &a, &v);
        segt.add(a, v);
        pair<int, int> result = segt.maximum();
        printf("%d %d\n", result.first, result.second);
    }
    return 0;
}