x, y = 0, 0
θ = 90
loop do
  given = $<.gets.split(",").map(&:to_i)
  break if given == [0, 0]
  x += given[0] * Math.cos(Math::PI * θ / 180)
  y += given[0] * Math.sin(Math::PI * θ / 180)
  θ -= given[1]
end
puts x.to_i
puts y.to_i
