#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

typedef pair<ll, int> pli;
ll cnt[1000001];

int main()
{
    set<pli> st;

    int n, q;
    cin >> n >> q;
    rep(i, q)
    {
        int a, v;
        cin >> a >> v;
        st.erase(make_pair(-cnt[a], a));
        cnt[a] += v;
        st.insert(make_pair(-cnt[a], a));
        pli ans = *st.begin();

        cout << ans.second << " " << -ans.first << endl;
    }

    return 0;
}
