#include <iostream>                                                              
#include <stdio.h>
using namespace std;



class Participant {

    private:
        int id;
        int num_of_fish_on_hand;

    public:
        Participant(int id);
        ~Participant();
        int get_num_of_fish();
        void variation(int);
        int get_id();
};

Participant::Participant(int id){
    this->id = id;
    num_of_fish_on_hand = 0;
}

int Participant::get_id(){
    return this->id;
}

int Participant::get_num_of_fish(){
    return this->num_of_fish_on_hand;
}

void Participant::variation(int num){
    num_of_fish_on_hand += num;
}

Participant::~Participant(){

}
int main(void){

    int event_num,participant_num;
    scanf("%d %d",&participant_num, &event_num);

    Participant **p = new Participant*[participant_num];

    for (int i = 0; i < participant_num; i++) {
        p[i] = new Participant(i+1);
    }   

    int par,var;
    int max_num_fish,m_id;
    int tmp;
    for (int i = 0; i < event_num; i++) {
        max_num_fish = 0;
        m_id = 0;                                                                
        scanf("%d %d", &par, &var);
        p[par-1]->variation(var);

        for (int j = 0; j < participant_num; j++) {

            tmp = p[participant_num-(j+1)]->get_num_of_fish();
            if( tmp >= max_num_fish){
                max_num_fish = tmp;
                m_id = p[participant_num-(j+1)]->get_id();
            }

        }

        cout << m_id << " " << max_num_fish << endl;
    }


    for (int i = 0; i < participant_num; i++) {
        delete p[i];
    }

    delete [] p;
    return 0;
}