def init
  x = 1
  while x <= $n
    x <<= 1
  end
  $n = x
  $arr = [0] * (2 * $n - 1)
end
 
def update(i, m)
  x = i
  i += $n - 1
  $arr[i] += m
  f = true
  while i > 0
    i = (i - 1) / 2
    if i > 0 && $arr[i] == [$arr[i*2+1], $arr[i*2+2]].max
      f = false
      break
    end
    $arr[i] = $arr[i*2+1] >= $arr[i*2+2] ? $arr[i*2+1] : $arr[i*2+2]
  end
  if f
    $idx = query(x) - $n + 1
    $max = $arr[0]
  end
end

def query(k)
  i = 0
  while i < $n
    i = $arr[i*2+1] >= $arr[i*2+2] ? i*2+1 : i*2+2
  end
  i
end

$n, q = gets.split.map(&:to_i)
init
$idx = $max = 0
q.times do
  update(*gets.split.map(&:to_i))
  puts "#{$idx} #{$max}"
end