#include<stdio.h>
#include<math.h>

typedef long double ldouble;

const double PI = acos(-1.0);
const double eps = 1e-10;
int main()
{
	int d,t;
	double x=0,y=0;
    int dir = 0;
	while(scanf("%d,%d", &d, &t) &&(d!=0||t!=0))			//霎灘?0,0扈捺據
	{
		x -= d * sin((dir) * PI / 180.0);						//隶。邂?		y += d * cos((dir) * PI / 180.0);
	    dir -= t;
	}
	printf("%d\n%d\n", (int)x, (int)y);					//霎灘?

	return 0;
}