require "matrix"

arr = Array.new
while line = gets
   a = line.split(",")
   a.map!{|j| j.to_i}
   if a[0] == 0 and a[1] == 0
      break
   end
   arr << a
end
d = 90
p = Vector[0, 0]
arr.each do |i|
   length, degree = i[0], i[1]
   r = 2 * (d / 360.0) * Math::PI
   p += length * Vector[Math.cos(r), Math.sin(r)]
   d -= degree
end
puts p[0].to_i
puts p[1].to_i