#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] = {};
int maxx[2] = {};
vector<int>part;




int main(void) {
	CI n >> event;

	max_[1] = 0;
	
	part.resize(n, 0);

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

			}
		}
		else {
			if (max_[0] == num) {
				for (int j = 0; j < n; ++j) {
					if (maxx[1] < part[j]) {
						maxx[1] = part[j];
						maxx[0] = j + 1;
					}
				
				}
				max_[0] = maxx[0];
				max_[1] = maxx[1];
				maxx[0] = 0;
				maxx[1] = 0;
			}
		}

		CO max_[0] << ' ' << max_[1] E
	}
	

	
	return 0;
}