//Aizu - 0016 : Treasure Hunt
#include<stdio.h>
#include<math.h>

#define PAI acos(-1.0)

int main()
{
	int d,t,ang=0;
	double x=0,y=0;

	while(scanf("%d,%d",&d,&t)&&(!(d==0&&t==0)))
	{
		x+=d*sin(PAI*ang/180.0);
		y+=d*cos(PAI*ang/180.0);
		ang+=t;
	}

	printf("%d\n%d\n",(int)x,(int)y);

	return 0;
}