#include <cstdio>
#include <algorithm>
#include <utility>
#include <climits>

using namespace std;

struct S {
    int n, v;
    S() {
        v = INT_MIN;
    }
    S(int n, int v) : n(n), v(v) {}
    bool operator<(const S &o) const {
        if (v == o.v) {
            return n > o.n;
        } else {
            return v < o.v;
        }
    }
};

struct SegTree {
    // root: vs[1]
    S *vs;
    int n;
    SegTree(int _n) {
        n = 1;
        while (n < _n) n *= 2;
        vs = new S[2 * n];
        for (int i = n + 1; i < 2 * n; i++) {
            vs[i].n = i - n;
            vs[i].v = 0;
        }
    }
    void add(int index, int v) {
        //printf("\t%d %d\n", vs[1].n, vs[1].v);
        index += n;
        vs[index].v += v;
        index /= 2;
        while (index > 0) {
            vs[index] = max(vs[index*2], vs[index*2+1]);
            index /= 2;
        }
    }
    int get(int index) {
        return vs[index + n].v;
    }
    S maximum() {
        return 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);
        S result = segt.maximum();
        printf("%d %d\n", result.n, result.v);
    }
    return 0;
}