#include<bits/stdc++.h>
using namespace std;
#define rep(i,a) for(int i = 0; i < (a); i++)
#define reps(i, a, b) for(int i = (a); i < (b); i++)
#define INF 1e9
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int, int> pii;
class Data {
	public:
	int index;
	int value;
	Data(){}
	Data(int index, int value): index(index), value(value){}
	bool operator<(const Data& s) const {
		if(value == s.value) return index > s.index;
		return value < s.value;
	}
};
class Seg {
	public:
	int size;
	vector<Data> dat;
	void init(int _size) {
		size = 1;
		while (size < _size) size *= 2;
		dat = vector<Data>(size *= 2);
	}
	void update(int i, Data x) {
		i += size - 1;
		dat[i].index = x.index;
		dat[i].value += x.value;
		while(i > 0) {
			i = (i - 1) / 2;
			dat[i] = max(dat[i * 2 + 1], dat[i * 2 + 2]);
		}
	}
	inline Data query() {
		return dat[0];
	}
};


int main() {
	int n,q;
	Seg seg;
	seg.init(n);
	cin >> n >> q;
	rep(i, q) {
		int a,v;
		cin >> a >> v;
		seg.update(a,Data(a,v));
		auto p = seg.query();
		cout << p.index << " " << p.value << endl;
	}
	return 0;
}