
#include <bits/stdc++.h>
#define MAX_N 1000000
using namespace std;
int n, q;
struct Human {
    int no;
    int point;
};

int compareTo(const Human& h1, const Human& h2) {
    if(h1.point > h2.point) return(1);
    else if(h1.point < h2.point) return(0);
    
    if(h1.no < h2.no) return(1);
    else return(0);
}

int main(void) {
    cin >> n >> q;
    Human player[MAX_N];
    int idx = 0;
    for(int r = 0; r < q; r++) {
        int no, point; cin >> no >> point;
        if(no <= idx) {
            player[no-1].point += point;
            //printf("value:%d\n", player[no].point);
        } else {
            player[idx].no = no; player[idx++].point = point;
        }
        Human temp[idx];
        for(int r = 0; r < idx; r++) temp[r]=player[r];
        sort(temp, temp+idx, compareTo);
        printf("%d %d\n", temp[0].no, temp[0].point);
    }
    return(0);
}