def aux(f)
  x=0.0
  y=0.0
  dir=0.0
  while f.length > 0
    d,t=f.shift()
    break if d==0 and t==0
    x += d.to_f * Math.sin(dir*Math::PI/180.0)
    y += d.to_f * Math.cos(dir*Math::PI/180.0)
    dir += t.to_f
  end
  [x.to_i,y.to_i]

end

def main
  f=[]
  fh=STDIN
  #fh=File.new("x.txt", "r")
  while fh.gets
    l = $_.strip.chomp.split(/,/)
    f.push(l)
  end
  puts aux(f)
end

if $0 == __FILE__ then
  main
end
