#include <iostream>
using namespace std;
 
int main()
{
    int number = 0,ive,max = 0,top = 1,num;
    cin >> number >> ive;
    int men[1000001] = {0};
    int numbers = number;
    for(int i = 0; i < ive; i++){
        cin >> number >> num;
        men[number] += num;
        if(num > 0){
            if(men[number] >= max){
                if(men[number] == max){
                    if(top > number){
                        top = number;
                        max = men[number];
                    }
                }else{
                    top = number;
                    max = men[number];
                }
                cout << top << " " << max << endl;
            }else{
                cout << top << " " << max << endl;
            }
        }else{
            if(number == top){
                if(men[number] < max){
                    max = 0;
                    top = 0;
                    for(int k = numbers; k > 0; k--){
                        if(max <= men[k]){
                            top = k;
                            max = men[k];
                        }
                    }
                    cout << top << " " << max << endl;
                }
            }else{
                cout << top << " " << max << endl;
            }
        }
    }
        return 0;
}