#include<bits/stdc++.h>
using namespace std;priority_queue<pair<int,int> >Q;int n,q,a,b,d[1000010];int main(){cin>>n>>q;a=n;while(a--)Q.push(make_pair(0,a)),d[a]=0;while(q--){cin>>a>>b;a=n-a,d[a]+=b;Q.push(make_pair(d[a],a));while(1){a=Q.top().first,b=Q.top().second;if(d[b]==a){cout<<n-b<<" "<<a<<endl;break;}Q.pop();}}return 0;}