#include <algorithm>
#include <iostream>
#include <set>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)

const int INF = 1001001001;

int main()
{
    int n, q;
    cin >> n >> q;
    
    set<pii> S;
    unordered_map<int, int> m;
    
    rep(i, q){
        int a, v;
        cin >> a >> v;
        if(m.count(a)) S.erase(pii(m[a], a));
        m[a] -= v;
        S.insert(pii(m[a], a));
        cout << S.begin()->second << ' ' << -S.begin()->first << endl;
    }
}