#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define minit(a,b) memset(a, b, sizeof(a))

typedef pair< int, int > pii;

int n, q, A[1000010];

int main() {
	cin >> n >> q;
	
	minit(A, 0);
	priority_queue< pii > que;
	
	for_(i,0,q) {
		int a, v;
		cin >> a >> v;
		
		A[a-1] += v;
		que.push(pii(A[a-1], -a));
		
		while (1) {
			pii p = que.top();
			int id = -p.second;
			int AA = p.first;
			
			if (A[id-1] == AA) {
				cout << id << " " << AA << endl;
				break;
			} else {
				que.pop();
			}
		}
	}
}