r = 0
x, y = 0, 0
readlines.each do |l|
  length, angle = l.split(",").map(&:to_i)
  x += length * Math.sin(r)
  y += length * Math.cos(r)
  r += angle * Math::PI / 180
end
puts x.truncate
puts y.truncate