#include <bits/stdc++.h>

constexpr const int NMAX = 1000000;

int max(std::array<int, NMAX> const &p, int n) {
    int maxid = 0;
    int maxval = p[0];
    for (int i = 1; i < n; i++) {
        if (maxval < p[i]) maxid = i;
    }
    return maxid;
}

int main(void)
{
    int n;
    int q;
    std::cin >> n >> q;

    std::array<int, NMAX> p;
    p.fill(0);

    int curmaxid = 0, dist = 0;
    for (int i = 0; i < q; i++) {
        int pid, delta;
        std::cin >> pid >> delta;
        pid--;

        p[pid] += delta;
        if (curmaxid == pid) {
            dist += delta;
            if (delta < 0) {
                if (dist <= 0) {
                    curmaxid = max(p,n);
                }
            }
        } else if (p[pid] > p[curmaxid]) {
            dist = p[pid] - p[curmaxid];
            curmaxid = pid;
        }
        std::cout << curmaxid+1 << " " << p[curmaxid] << std::endl;
    }
    
    return 0;
}