### main

n = gets.to_i

n.times do
  x = y = 0
  max_d2 = 0
  max_x = max_y = 0

  loop do
    dx, dy = gets.split.map(&:to_i)
    break if (dx | dy) == 0

    x += dx
    y += dy
    d2 = x * x + y * y

    if max_d2 < d2
      max_d2 = d2
      max_x = x
      max_y = y
    elsif max_d2 == d2 && max_x < x
      max_x = x
      max_y = y
    end
  end

  puts [max_x, max_y].join(' ')
end