#!/usr/bin/ruby
class Locate
   def initialize()
      @x=0
      @y=0
      @m=0
   end
   def go(r,s)
      @x+=r*Math.sin(Math::PI/180*@m)
      @y+=r*Math.cos(Math::PI/180*@m)
      @m+=s
   end
   def show
      return {"x"=>@x.floor,"y"=>@y.floor}
   end
end
obj=Locate.new
loop{
   buf=gets.chop
   buf=(buf.split(",")).map{|e| e.to_i}
   if buf[0] == 0 and buf[1] == 0 then 
      break
   end
   obj.go(buf[0],buf[1])
}
   buf=obj.show
   puts(buf["x"])
   puts(buf["y"])