n = gets.to_i
n.times{|i|
    x, y, farthest = 0, 0, [-1, -1, -1]
    while true
        dx, dy = gets.chomp.split.map(&:to_i)
        break if [dx, dy] == [0, 0]
        x, y = x + dx, y + dy
        d = x * x + y * y
        farthest = [d, x, y] if (farthest[0] < d || (farthest[0] == d && farthest[1] < x))
    end
    puts "#{farthest[1]} #{farthest[2]}"
}
