now, angle, rad = [0,0], 0, 0
loop{
   line = gets.split(',').map(&:to_i)
   if line == [0,0]
	  break
   else
	  rad = Math::PI * angle / 180
	  now = [now[0] + line[0] * Math.sin(rad), now[1] + line[0] * Math.cos(rad)]
	  angle = angle + line[1]
   end
}
puts now[0].to_i
puts now[1].to_i