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

using namespace std;

int main() {
    int max = -1;
    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;

        if (m[max] < m[a - 1])
            max = a - 1;

        cout << max + 1 << " " << m[max] << "\n";
    }
}