


fun main(args: Array<String>?): Unit {
    repeat(readLine()!!.trim().toInt()) {
        var current = Coordinate(0, 0)
        var max = current
        while (true) {
            val (dx, dy) = readLine()!!.trim().split(' ').map(String::toInt)
            if (dx == 0 && dy == 0) break
            current += Coordinate(dx, dy)
            if (current.norm2() > max.norm2() || (current.norm2() == max.norm2() && current.x > max.x)){
                max = current
            }
        }
        println("${max.x} ${max.y}")
    }
}

data class Coordinate(val x: Int, val y: Int) {
    operator fun plus(that: Coordinate): Coordinate = Coordinate(x + that.x, y + that.y)
    operator fun minus(that: Coordinate): Coordinate = Coordinate(x - that.x, y - that.y)
    fun norm2(): Int = x * x + y * y
}
