# coding: utf-8

class Treasure
  include Math
  def hunt
    x, y = 0, 0
    current_kakudo = 90

    loop do
      hosu, kakudo = gets.chomp.split(",").map {|s| s.to_f}
      break if hosu == 0 && kakudo == 0

      x += hosu * cos(current_kakudo * Math::PI / 180)
      y += hosu * sin(current_kakudo * Math::PI / 180)

      current_kakudo -= kakudo
    end
    print "#{x.to_i}\n#{y.to_i}\n"
  end
end

Treasure.new.hunt