#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int qx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int qy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(void) {
	ll n, q;
	cin>>n>>q;
	vector<ll> hoge(n, 0);
	vector<P> hogeho(n);
	REP(i, n) {
		hogeho[i].first = 0;
		hogeho[i].second = i;
	}
	REP(i, q) {
		ll a, v;
		cin>>a>>v;
		--a;
		ll gomi = hoge[a];
		hoge[a] += v;
		vector<P>::iterator ite;
		ite = lower_bound(ALL(hogeho), P(gomi, a));
		(*ite).first = hoge[a];
		sort(ALL(hogeho));
		ite = lower_bound(ALL(hogeho), P(hogeho[hogeho.size() - 1].first, 0));
		cout<<(*ite).second + 1<<" "<<(*ite).first<<endl;
	}
}