x,y = 0.0,0.0
theta = 90
while true
    a,b = gets.split(",").map(&:to_i)
    break if (a == 0) and (b == 0)
    x += a * Math::cos(Math::PI * theta / 180.0)
    y += a * Math::sin(Math::PI * theta / 180.0)
    theta -= b
end
printf("%d\n%d\n",x,y)