def deg2rad(a)
	return a / 180.0 * Math::PI
end

s = 0.0
x = 0.0
y = 0.0

while line = gets do
	h, r = line.split(',').map(&:to_i)
	if h == 0 && r == 0 then
		break
	end
	
	x += Math.sin(deg2rad(s)) * h
	y += Math.cos(deg2rad(s)) * h

	s += r
	if s > 180.0 then
		s -= 360.0
	elsif s < -180.0 then
		s += 360.0
	end
end

puts x.to_i
puts y.to_i