x, y, a = 0, 0, 90
while s = gets
  r, aa = s.split(',').map(&:to_i)
  break if r == 0 && aa == 0
  x += r * Math.cos(a * Math::PI/180)
  y += r * Math.sin(a * Math::PI/180)
  a -= aa
end
puts x.to_i
puts y.to_i