#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};
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
typedef vector<vector<int> > VVI;
const int INF = 1e9;
typedef pair<int, int> PII;

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

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

int N;

void update(int n, int value)
{
	nums[n] += value;
	
	bucket[n/B] = PII(-INF, -1);
	for (int i=(n/B)*B; i<min(N, (n/B+1)*B); i++) {
		if (bucket[n/B].first < nums[i]) {
			bucket[n/B].first = nums[i];
			bucket[n/B].second = i;
		}
	}
}

int main()
{
	int 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;
		
		a--;
		update(a, v);
		
		PII ans(-INF, -1);
		for (int i=0; i<=N/B; i++) {
			if (ans.first < bucket[i].first) {
				ans.first = bucket[i].first;
				ans.second = bucket[i].second;
			}
		}
		
		cout << ans.second+1 << " " << ans.first << endl;
	}
}