#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
//#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int d[1000001];
set<pii> st;

signed main() {
    int n, q;
    cin >> n >> q;
    rep(i, 0, n){
        st.insert(make_pair(0, i));
    }
    rep(i, 0, q){
        int a, v;
        cin >> a >> v;
        a--;
        st.erase(st.find(make_pair(d[a], a)));
        d[a] -= v;
        st.insert(make_pair(d[a], a));
        set<pii>::iterator it = st.begin();
        cout << it->se + 1 << " " << -it->fi << endl;
    }
}