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

#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);

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

        // 変更があったプレイヤーと現在の最大値を比較
        if ( player[i-1] > player[max_id] ) {
            max_id = i-1;

        // リリースが起こったときは検索
        } else if ( dif < 0 ) {
            int mid = 0;
            REP(i, n) {
                if ( player[i] > player[mid] ) mid = i;
            }
            max_id = mid;
        }

        cout << max_id+1 << " " << player[max_id] << endl;
    }

    return 0;
}