#include<iostream>
#include<queue>
using namespace std;
int n;

int main(){
	int q,num,v,max,maxnum;
	
	cin >> n >> q;
	int wakasagi[100000];
	priority_queue<pair<int, int> > pq;
	max = wakasagi[1];
	maxnum=1;
	for(int i=0;i<q;i++){
		 cin >> num >> v;
		 wakasagi[num] += v;
		 pq.push(make_pair(wakasagi[num],-num));
		  for(;;){
            int b = -pq.top().second;
            int w = pq.top().first;
            if(wakasagi[b] == w){
                cout << b << ' ' << w << endl;
                break;
            }
            pq.pop();
        }
		 
	}
	
	
	
}