#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
 
using namespace std;
 
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-7;

set<pii> st;
vi v;

int main(){
	int n, q;
	cin>>n>>q;
	v = vi(n+1, 0);
	rep(i, n){
		st.insert(mp(0, i+1));
	}
	int a, b;
	pii p;
	rep(i, q){
		cin>>a>>b;
		st.erase(st.find(mp(v[a], a)));
		v[a]-=b;
		st.insert(mp(v[a], a));
		p = *st.begin();
		cout<<p.se<<" "<<-p.fi<<endl;
	}
}
 