x = y = 0.0
deg = 90
while line = gets
  d, a = line.split(',').map(&:to_i)
  break if d.zero? && a.zero?

  rad =  (Math::PI / 180) * deg
  x += d * Math.cos(rad)
  y += d * Math.sin(rad)
  deg -= a
end

printf("%d\n%d\n", x, y)