#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define INF (1<<29)

typedef vector<int> vi;

int main() {
	int n, q;
	cin >> n >> q;
	vi v(n + 1, -INF);
	
	int ans = 0;
	REP(i, q) {
		int a, b;
		scanf("%d %d", &a, &b);
		if (v[a] == -INF)
			v[a] = b;
		else
			v[a] += b;
		if (v[ans] < v[a]) ans = a;
		printf("%d %d\n", ans, v[ans]);
	}
	return 0;
}