include Math
x,y=0,0
th=90
while true
    
    r,angle=gets.chomp.split(",").map(&:to_i)
    break if (r==0) && (angle==0)
    x+=r*cos(th/180.0*PI)
    y+=r*sin(th/180.0*PI)
    th-=angle
end
puts x.to_i,y.to_i