#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define MAX_N 1000000
#define MAX_Q 100000
#define INF -1
using namespace std;

struct Human {
    int no;
    int point;
};
typedef struct Human Human;

int compareTo(const Human a, const Human b) {
    return(a.point > b.point);
}

void output(int nowData[], int n) {
    Human nowData_cp[n + 1];
    nowData_cp[0].no = INF;
    nowData_cp[0].point = INF;
    for(int r = 1; r <= n; r++) {
        nowData_cp[r].no = r;
        nowData_cp[r].point = nowData[r];
        //printf("data: %d, %d", nowData_cp[r].no, nowData_cp[r].point);
        //printf("data: %d, %d", r, nowData[r]);
    }
    sort(nowData_cp, nowData_cp+n+1, compareTo);
    printf("%d %d\n", nowData_cp[0].no, nowData_cp[0].point);
}

int main(void) {
    int n, q; cin >> n >> q;
    int nowData[n + 1];
    memset(nowData, 0, sizeof(nowData));
    for(int r = 0; r < q; r++) {
        int no, point; cin >> no >> point;
        nowData[no] += point;
        output(nowData, n);
    }
    
    return(0);
}