#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>
 
#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

const int INF = 1e9;

using namespace std;

typedef pair<int, int> PII;

const int MAX = 1e6;
const int B = 1000;

int nums[MAX];
int bucket[MAX/B];

void update(int n, int value)
{
	nums[n] += value;
	bucket[n/B] = max(nums[n], bucket[n/B]);
}

PII get_max(int l, int r)
{
	PII res(-INF, -1);
	int L = l/B, R = r/B;
	
	if (L != R) {
		for (int i=l; i<(L+1)*B; i++) {
			if (res.first < nums[i]) {
				res.first = nums[i];
				res.second = i;
			}
		}
		for (int i=(L+1)*B; i<R*B; i++) {
			if (res.first < nums[i]) {
				res.first = nums[i];
				res.second = i;
			}
		}
		for (int i=R*B; i<r; i++) {
			if (res.first < nums[i]) {
				res.first = nums[i];
				res.second = i;
			}
		}
	} else {
		for (int i=l; i<r; i++) {
			if (res.first < nums[i]) {
				res.first = nums[i];
				res.second = i;
			}
		}
	}
	return res;
}

int main()
{
	int N, Q;
	cin>>N>>Q;
	
	memset(nums, 0, sizeof(nums));
	memset(bucket, 0, sizeof(bucket));
	
	for (int q=0; q<Q; q++) {
		int a, v; 
		cin>>a>>v;
		
		update(a, v);
		cout << get_max(0, N).second << " " << get_max(0, N).first << endl;	
	}
}