#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>

using namespace std;

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

const ll MOD = ll(1e9) + 7;
const ll INF = LLONG_MAX;
const ll MAX_N = 1 << 20;
const double EPS = 10e-8;
const double PI = 3.14159265359;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)

ll n;
P dat[2 * MAX_N - 1];

void init(ll n_) {
    n = 1;
    while (n < n_) {
        n *= 2;
    }
    REP(i, 2 * n - 1) dat[i] = {-INF, -INF};
    REP(i, n_) {
        ll k = i + n - 1;
        dat[k] = {0, i};
    }
}

P comp(P d1, P d2) {
    if (d1.first > d2.first) {
        return d1;
    } else if (d1.first < d2.first) {
        return d2;
    } else {
        return min(d1, d2);
    }
}

void update(ll k, ll a) {
    k += n - 1;
    dat[k].first += a;
    while (k > 0) {
        k = (k - 1) / 2;
        dat[k] = comp(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
}

P query(ll a, ll b, ll k, ll l, ll r) {
    if (r <= a || b <= l) 
        return {-INF, -INF};
    if (a <= l && r <= b)
        return dat[k];
    else {
        P vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
        P vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
        return comp(vl, vr);
    }
}

int main() {
    ll N, Q;
    cin >> N >> Q;
    init(N);
    REP(i, Q) {
        ll ai, vi;
        cin >> ai >> vi;
        ai--;
        update(ai, vi);
        P ans = query(0, N, 0, 0, n);
        cout << ans.second + 1 << " " << ans.first << endl;
    }

    return 0;
}

