include Math
theta = 90.0
puts $<.to_a.map{|i|i.split(',')}.map{|i|i.map(&:to_i)}.collect{|a|
  ret = [a[0] * cos(theta*PI/180.0), a[0] * sin(theta*PI/180.0)]
  theta -= a[1]
  ret
}.transpose.map{|i|i.inject(:+)}.join("\n")