#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <utility>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;
typedef pair<ll, int> P;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

template<typename T, T Func(T, T)>
class SegmentTree {
    vector<T> data;
    int n;
    T init;

public:
    SegmentTree(int _n, T _init) {
        n = 1;
        while (n < _n) {
            n *= 2;
        }
        init = _init;
        data.resize(2 * n - 1, init);
    }
    void update(int pos, T val) {
        pos += n - 1;
        //data[pos] = F(data[pos], val);
        data[pos] += val;
        while (pos > 0) {
            pos = (pos - 1) / 2;
            data[pos] = Func(data[2 * pos + 1], data[2 * pos + 2]);
        }
    }
    T query(int l, int r) {
        return query(l, r, 0, n, 0);
    }
    T query(int l, int r, int a, int b, int x) {
        if (b <= l || r <= a) return T(0, n + 1);
        if (l <= a && b <= r) return data[x];
        int mid = (a + b) / 2;
        return Func(query(l, r, a, mid, 2 * x + 1), query(l, r, mid, b, 2 * x + 2));
    }
};

P Max(P a, P b) {
    if (a.first != b.first) {
        return a.first > b.first ? a : b;
    } else {
        return a.second < b.second ? a : b;
    }
}

namespace std {
    P operator+=(P &a, P b) {
        a.first += b.first;
        a.second += b.second;
        return a;
    }
}  // namespace std

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    SegmentTree<P, Max> seg(n, P(0, 0));
    REP (i, 0, n) {
        seg.update(i, P(0, i + 1));
    }
    REP(i, 0, q) {
        int a, v;
        cin >> a >> v;
        seg.update(a - 1, P(v, 0));
        auto res = seg.query(0, n);
        cout << res.second << " " << res.first << endl;
    }
    return 0;
}

