x = 0; y = 0; th = 90
while gets do
  r, rot = $_.split(/,/).map(&:to_i)
  break if r == 0 && rot == 0
  x += r * Math.cos(th/180.0*Math::PI)
  y += r * Math.sin(th/180.0*Math::PI)
  th -= rot
end
puts x.truncate, y.truncate