#coding:utf-8
include Math

x,y = 0.0,0.0
dir = 0.0 

step,angle = 0,0
while !STDIN.eof? do
	str = gets.chomp.split(',').map(&:to_i)
	break if str==[0,0]
	step,angle = str[0], str[1]
	
	
	#進行方向の決定
	rad = dir.to_f*Math::PI/180.0
	x += sin(rad)*step
	y += cos(rad)*step

	dir += angle
	
end

puts x = x.to_i
puts y = y.to_i