#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<queue>
#include <algorithm>
#include<functional>


#define CI cin >>
#define CO cout <<
#define E << endl;
#define F(i,max) (for(int i = 0;i < max;++i))

using namespace std;

int n = 0;
int num = 0;
int fish = 0;
int event = 0;
int max_[2] = {};
vector<int>part;




int main(void) {
	CI n >> event;
	
	part.resize(n, 0);

	for (int i = 0; i < event; ++i) {
		CI num;
		CI fish;
		part[num - 1] += fish;
		if (max_[1] < part[num - 1]) {
			max_[0] = num;
			max_[1] = part[num - 1];
		}
		CO max_[0] << ' ' << max_[1] E
	}
	

	
	return 0;
}