#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define EQ(a,b) (abs((a)-(b))<EPS)
int seg[(1<<21)-1];
void add(int m,int score)
{
	m+=(1<<20)-2;
	seg[m]+=score;
	while(m>0)
	{
		m=(m-1)/2;
		seg[m]=max(seg[m*2+1],seg[m*2+2]);
	}
	return;
}
int find()
{
	int res=0;
	while(res<(1<<20)-1)
	{
		if(seg[0]==seg[res*2+1])res=res*2+1;
		else res=res*2+2;
	}
	return res-(1<<20)+2;
}
int main()
{
	int n,q;
	cin >> n >> q;
	for(int i=0;i<q;i++)
	{
		int a,v;
		cin >> a >> v;
		add(a,v);
		cout << find() << ' ' << seg[0] << endl;
	}
	return 0;
}