#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <functional>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long
//#define scanf scanf_s

int n, q;
int a[1000005];
priority_queue<pair<int,int>> pque;

int main()
{
	cin >> n >> q;
	REP(i, n) a[i] = 0;
	REP(i, q)
	{
		int x, y;
		cin >> x >> y;
		a[x] += y;
		pque.push(make_pair(a[x], -x));
		int ansf, ansp;
		ansf = pque.top().first;
		ansp = pque.top().second;
		cout << -ansp << " " << ansf << endl;
	}
	return 0;
}