#include <iostream>
#include <stdlib.h>
#include <sstream>

using namespace std;

int* max(int* arr, int size, int* mxi) {
    for (int i = 0; i < size; i++) {
        if (mxi[1] < arr[i]) {
            mxi[0] = i;
            mxi[1] = arr[i];
        }
    }
    return mxi;
}

int main() {
    int n, q;
    cin >> n >> q;
    int* m = (int*)malloc(sizeof(int) * n);

    for (int i = 0; i < n; i++)
        m[i] = 0;

    for (int i = 0; i < q; i++) {
        int a, v;
        cin >> a >> v;
        m[a - 1] += v;
        int mxi[] = {-1, -1};
        max(m, n, mxi);
        cout << mxi[0] + 1 << " " << mxi[1] << "\n";
    }
}