import queue

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

p=queue.PriorityQueue()

s=[0]*-~n

for _ in[0]*q:

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

 s[a]+=v;p.put((-s[a],a))

 while 1:

  t=p.get()

  if -t[0]==s[t[1]]:print((t[1],-t[0]));p.put(t);break

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 queue

n, q = list(map(int, input().split()))
p = queue.PriorityQueue()
s = [0] * -~n
for _ in [0] * q:
    a, v = list(map(int, input().split()))
    s[a] += v
    p.put((-s[a], a))
    while 1:
        t = p.get()
        if -t[0] == s[t[1]]:
            print((t[1], -t[0]))
            p.put(t)
            break

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 queue +import sys -p = queue.PriorityQueue() -for _ in [0] * q: -    a, v = list(map(int, input().split())) +w = m = 0 +for e in sys.stdin: +    a, v = list(map(int, e.split())) -    p.put((-s[a], a)) -    while 1: -        t = p.get() -        if -t[0] == s[t[1]]: -            print((t[1], -t[0])) -            p.put(t) -            break +    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))