#include <iostream>
#include <string>
#include <vector>

#define TIMES(i) while(i--)
#define REP(i, n) for ( int i = 0; i < n; i++ )

using namespace std;

int main() {
    int n, q;

    cin >> n >> q;

    vector<int> player(n, 0);

    TIMES(q) {
        int i, dif, max_i = 0;
        cin >> i >> dif;
        player[i-1] += dif;

        REP(i, n) {
            if ( player[i] > player[max_i] ) {
                max_i = i;
            }
        }
        cout << max_i+1 << " " << player[max_i] << endl;
    }

    return 0;
}