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

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

typedef pair< int, int > pii;

class SegmentTree {
private:
	int size__;
	vector< pii > data;
	
	inline int left_t(int k) { return 2 * k + 1; }
	inline int right_t(int k) { return 2 * k + 2; }
	
public:
	SegmentTree(int n) {
		for (size__ = 1; size__ < n; size__ *= 2);
		data.assign(2 * size__ - 1, pii(0, -(1e9)));
	}
	
	pii calc(pii d1, pii d2) { return max(d1, d2); }
	
	void add(int k, int a) {
		int id = -k;
		k += size__ - 1;
		
		int cur = data[k].first;
		data[k] = pii(cur + a, id);
		
		while (k > 0) {
			k = (k - 1) / 2;
			data[k] = calc(data[left_t(k)], data[right_t(k)]);
		}
	}
	
	pii query(int a, int b) {
		return query(a, b, 0, 0, size__);
	}
	
	pii query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return pii(-1, -(1e9));
		if (a <= l && r <= b) return data[k];
		return calc(query(a, b, left_t(k), l, (l + r) / 2),
					query(a, b, right_t(k), (l + r) / 2, r));
	}
};

int main() {
	int n, q;
	cin >> n >> q;
	
	SegmentTree segtree(n);
	for_(i,0,n) segtree.add(i, 0);
	
	for_(i,0,q) {
		int a, v;
		cin >> a >> v;
		
		segtree.add(a-1, v);
		
		pii maxp = segtree.query(0, n+1);
		cout << (-maxp.second) + 1 << " " << maxp.first << endl;
	}
}