deg = Math::PI/2
x = 0.0;y = 0.0
until (s=gets.chomp) == "0,0" do
    diff = s.split(",").map(&:to_i)
    x += diff[0]*Math.cos(deg)
    y += diff[0]*Math.sin(deg)
    deg -= (diff[1]*Math::PI/180.0)
end
puts x.to_i, y.to_i