angle = 0.0
x = 0.0
y = 0.0
while n = gets do
  h, a = n.split(",").map(&:to_i)
  break if h == 0 && a == 0
  x = x + Math.sin(angle * Math::PI / 180.0) * h 
  y = y + Math.cos(angle * Math::PI / 180.0) * h
  angle = angle + a
end
puts x.to_i
puts y.to_i