#include<stdio.h>
#include <string.h>

int Nmem,act;
int cou=1;
int memo[1000001];
int num,fish;
long int maxmemo[2]={0};
int scanset[100001];

int maxset(int num,int n)
{
    maxmemo[0]=num;
    maxmemo[1]=memo[num];
    return 0;
}

int main()
{
    maxmemo[0]=1000001;
    memset(memo,-1,1000001);
    scanf("%d%d",&Nmem,&act);
    for(int i=0;i<act;i++)
    {
        scanf("%d%d",&num,&fish);
        if(memo[num]==-1)
        {
            scanset[cou]=num;
            cou++;
            memo[num]++;
        }
        memo[num]=memo[num]+fish;
        if(fish>0)
        {
            if(maxmemo[1]<=memo[num])
            {
                if(memo[num]==maxmemo[1]&&num>maxmemo[0]){}
                else maxset(num,0);
            }
            printf("%lld %lld\n",maxmemo[0],maxmemo[1]);
        }
        else if(fish<0)
        {
            for(int i=0;i<2;i++)
            {
                maxmemo[0]=1000001;
                maxmemo[1]=0;
            }
            for(int i=0;i<cou;i++)
            {
                if(memo[scanset[i]]>=maxmemo[1])
                {
                    if(memo[scanset[i]]==maxmemo[1]&&scanset[i]>maxmemo[0]){}
                    else maxset(i,0);
                }
            }
            printf("%lld %lld\n",maxmemo[0],maxmemo[1]);
        }
    }
    return 0;
}