class TreasuerHunt
  def initialize
    @angle = deg_to_rad(90)
    @x = 0.0
    @y = 0.0
  end

  def move(dist, deg)
    @x += Math.cos(@angle) * dist
    @y += Math.sin(@angle) * dist
    rad = deg_to_rad(deg)
    @angle -= rad
  end

  def deg_to_rad deg
    deg * (Math::PI / 180)
  end

  def x
    @x
  end

  def y
    @y
  end

end

pos = TreasuerHunt.new

while line = gets do
  dist, deg = line.chomp.split(',')
  break if dist.to_i == 0 && deg.to_i == 0
  pos.move(dist.to_i, deg.to_i)
end
puts pos.x.to_i
puts pos.y.to_i