#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    int n, q;
    cin >> n >> q;

    vector<int> x(n+1, 0);
    set<pair<int, int> > s;
    for(int i=1; i<=n; ++i)
        s.insert(make_pair(0, i));

    for(int i=0; i<q; ++i){
        int a, v;
        cin >> a >> v;

        s.erase(make_pair(x[a], a));
        x[a] -= v;
        s.insert(make_pair(x[a], a));

        cout << s.begin()->second << ' ' << (-s.begin()->first) << endl;
    }

    return 0;
}