#include <iostream>
using namespace std;

int main()
{
    int n,q;
    int a,v;
    int array[1000001]={};
    int index, max_num;
    cin >> n >> q;
    index = n+1;
    max_num = 0;

    while(cin >> a >> v)
    {
        array[a] +=v;
        if(v>0)
        {
            if((array[a] > max_num) || ((array[a] == max_num) && a < index))
            {
                index = a;
                max_num = array[a];                
            }
        }
        else
        {
            if(a == index)
            {
                index = n+1;
                max_num = 0;
                for(int i=1; i<=n; i++)
                {
                    if(array[i] > max_num)
                    {
                        index = i;
                        max_num = array[i];
                    }
                }
            }
        }
        cout << index << " " << max_num << endl;
    }
    return 0;
}