class Sambonmatsu
  def initialize
    @x = 0
    @y = 0
    @direct = 90
  end

  def calc
    while(input = $stdin.gets) do
      direct, rotate = input.chomp.split(',').map(&:to_i)
      if direct == 0 && rotate == 0
        break 
      end
      step(direct)
      @direct -= rotate
    end
    puts @x.truncate
    puts @y.truncate
  end

  def step(direct)
    thita = (@direct/360.0)*2*Math::PI
    @x += direct*Math.cos(thita)
    @y += direct*Math.sin(thita)
  end
end

s = Sambonmatsu.new
s.calc