import sys

n,q=list(map(int,input().split()))

s=[0]*-~n

w=m=0

for e in sys.stdin:

 a,v=list(map(int,e.split()))

 s[a]+=v

 if v<0 and a==w:m=max(s);w=s.index(m)

 elif s[a]>m:w,m=a,s[a]

 elif s[a]==m:w=min(w,a)

 print((w,m))

import sys

def f():

 w=m=0;n,q=list(map(int,input().split()));s=[0]*-~n

 for e in sys.stdin:

  a,v=list(map(int,e.split()));s[a]+=v

  if v<0 and a==w:m=max(s);w=s.index(m)

  elif s[a]>m:w,m=a,s[a]

  elif s[a]==m:w=min(w,a)

  print((w,m))

if'__main__'==__name__:f()

import sys

n, q = list(map(int, input().split()))
s = [0] * -~n
w = m = 0
for e in sys.stdin:
    a, v = list(map(int, e.split()))
    s[a] += v
    if v < 0 and a == w:
        m = max(s)
        w = s.index(m)
    elif s[a] > m:
        w, m = a, s[a]
    elif s[a] == m:
        w = min(w, a)
    print((w, m))

import sys


def f():
    w = m = 0
    n, q = list(map(int, input().split()))
    s = [0] * -~n
    for e in sys.stdin:
        a, v = list(map(int, e.split()))
        s[a] += v
        if v < 0 and a == w:
            m = max(s)
            w = s.index(m)
        elif s[a] > m:
            w, m = a, s[a]
        elif s[a] == m:
            w = min(w, a)
        print((w, m))


if "__main__" == __name__:
    f()

-n, q = list(map(int, input().split())) -s = [0] * -~n -w = m = 0 -for e in sys.stdin: -    a, v = list(map(int, e.split())) -    s[a] += v -    if v < 0 and a == w: -        m = max(s) -        w = s.index(m) -    elif s[a] > m: -        w, m = a, s[a] -    elif s[a] == m: -        w = min(w, a) -    print((w, m)) + +def f(): +    w = m = 0 +    n, q = list(map(int, input().split())) +    s = [0] * -~n +    for e in sys.stdin: +        a, v = list(map(int, e.split())) +        s[a] += v +        if v < 0 and a == w: +            m = max(s) +            w = s.index(m) +        elif s[a] > m: +            w, m = a, s[a] +        elif s[a] == m: +            w = min(w, a) +        print((w, m)) + + +if "__main__" == __name__: +    f()