#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define FORE(v, a, b) for(int v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define RS resize
#define CLR clear
#define PB push_back
#define ALL(x) (x).begin(), (x).end()
#define INF (~(1<<31))
#define N_INF (1<<31)
using namespace std;

void split(string str, char chr, vector< string > *res){
	stringstream ss(str);
	string itm;
	while(getline(ss, itm, chr)){
		(*res).PB(itm);
	}
}

class RangeMaxQuery{
private:
    vector< int > value;
    int _size;
public:
	
    void Init(int size){
        int bitcount = 0;
        int t = size;
         
        while(t != 0){
            t /= 2;
            ++bitcount;
        }
        if(size % (1 << (bitcount - 1)) != 0) bitcount++;
        _size = (1 << bitcount) - 1;
         
        value.resize(_size);
         
        for(vector< int >::iterator it = value.begin(); it != value.end(); ++it){
            (*it) = 0;
        }
    }
	
    void Update(int index, int v){
        int n = index + (_size>>1);
        value[n] += v;
         
        while(n > 0){
            n = (n - 1) / 2;
            value[n] = max(value[n * 2 + 1], value[n * 2 + 2]);
        }
    }
    
    void RunQuery(int *max, int *node){
    	*max = value[0];
    	*node = 0;
    	
    	while(*node < (_size>>1)){
    		if(value[2 * (*node) + 1] == *max){
    			*node = 2 * (*node) + 1;
    		}else{
    			*node = 2 * (*node) + 2;
    		}
    	}
    	
    	*node -= (_size >> 1);
    }
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, q, a, v, maximum, node;
	RangeMaxQuery rmq;
	
	cin >> n >> q;
	rmq.Init(n);
	
	REP(i, q){
		cin >> a >> v;
		
		rmq.Update(a - 1, v);
		rmq.RunQuery(&maximum, &node);
		
		cout << node + 1 << " " << maximum << endl;
	}
	return 0;
}