pi = 3.1415926535897931e+00
pos = [0.0, 0.0]
vec = [0.0, 1.0]
theta = 90.0
while line = gets
  break if line.chomp == "0,0"
  d, a = line.split(",").map(&:to_i)
  pos[0] += vec[0] * d
  pos[1] += vec[1] * d
  theta -= a
  vec = [Math.cos(theta/180.0*pi), Math.sin(theta/180.0*pi)]
end
puts pos[0].to_i
puts pos[1].to_i