#include<cstdio>
#include<cmath>

double rad=90.00000000000;//回転角
double x=0.0,y=0.0;//現在地
int answer_x,answer_y;
double PI=6*asin( 0.5 )/180;

int main()
{
	int a,b;
	while(scanf("%d,%d",&a,&b)!=EOF)
	{
		if(a==0&&b==0)break;
		y+=sin(rad*PI)*a;
		x+=cos(rad*PI)*a;
		rad=(rad-b);
	}
	if(x>0)answer_x=floor(x);
	else answer_x=ceil(x);
	if(y>0)answer_y=floor(y);
	else answer_y=ceil(y);
	printf("%d\n%d\n",answer_x,answer_y);
	return 0;
}