x, y, theta = 0.0, 0.0, 90
while true
    d, angle = gets.chomp.split(",").map(&:to_i)
    break if d == 0 && angle == 0

    rad = theta / 180.0 * Math::PI
    x += d * Math.cos(rad)
    y += d * Math.sin(rad)
    theta -= angle 
end
puts x.to_i
puts y.to_i