include "Math"

x, y = 0, 0
s = 90

while true
  d, si = gets.chomp.split(",").map(&:to_i)
  break if d == 0 && si == 0
  x += d * cos(2 * PI * s / 360)
  y += d * sin(2 * PI * s / 360)
  s += si
end

puts x.truncate
puts y.truncate