x, y, arg = 0, 0, 90 * Math::PI / 180

while line = gets do
  r, deg = line.split(",").map(&:to_i)
  x += r * Math.cos(arg)
  y += r * Math.sin(arg)
  arg -= deg * Math::PI / 180
  #p x, y
end

puts x.to_i, y.to_i