#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#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;

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...));
}

#include <functional>
template<typename T>
class SegmentTreeOneAll {
    using Func = function<T(T, T)>;

public:
    vector<T> data;
    int n;
    T init;
    Func update_func;
    Func query_func;
    SegmentTreeOneAll(int _n, T _init, Func up, Func qu) {
        init = _init;
        update_func = up;
        query_func = qu;
        for (n = 1; n < _n; n *= 2)
            ;
        data.resize(2 * n - 1, init);
    }
    void update(int pos, T val) {
        pos += n - 1;
        data[pos] = update_func(data[pos], val);
        while (pos > 0) {
            pos = (pos - 1) / 2;
            data[pos] = query_func(data[2 * pos + 1], data[2 * pos + 2]);
        }
    }
    T query(int l, int r) {
        T res = init;
        for (l += n - 1, r += n - 1; l < r; l = l / 2, r = (r - 1) / 2) {
            if (!(l & 1)) {
                res = query_func(res, data[l]);
            }
            if (!(r & 1)) {
                res = query_func(res, data[r - 1]);
            }
        }
        return res;
    }
};

#include <utility>
using P = pair<int, int>;
using SegmentTree = SegmentTreeOneAll<P>;

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

