#include<iostream>
#include<vector>
#include<climits>
#include<set>
#include<tuple>

using namespace std;


int main(void){
	int n,q;
	vector<int> as;
	vector<int> vs;
	set<pair<int,int> > ranking;
	vector<int> fishes;
	vector<int> ansAs;
	vector<int> ansVs;

	cin >> n >> q;
	for(int i=0;i<q;i++){
		int a, v;
		cin >> a >> v;
		as.push_back(a-1);
		vs.push_back(v);
	}
	for(int i=0;i<n;i++){
		fishes.push_back(0);
	}

	for(int i=0;i<q;i++){
		ranking.insert(pair<int,int>(0,-as[i]));
	}

	for(int i=0;i<q;i++){
		pair<int,int> old = pair<int,int>(fishes[as[i]],-as[i]);
		fishes[as[i]] += vs[i];
		pair<int,int> now = pair<int,int>(fishes[as[i]],-as[i]);
		ranking.erase(old);
		ranking.insert(now);
		set<pair<int,int> >::iterator itr = ranking.end();
		--itr;
		ansAs.push_back(-(itr->second));
		ansVs.push_back(itr->first);
	}


	for(int i=0;i<q;i++){
		cout << ansAs[i] + 1 << " " << ansVs[i] << endl;
	}

	return 0;
}