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

typedef long double ldouble;

const ldouble PI = acos(-1.0);
const ldouble eps = 1e-10;

ldouble mysin(ldouble x) {
    ldouble ret = 0.0, now = x, tt = x * x, k = 1;
    for(int i = 0; i < 1000; i++) {
        ret += now / k;
        now *= (-tt);
        k *= (2 * i + 2) * (2 * i + 3);
    }
    return ret;
}

ldouble mycos(ldouble x) {
    ldouble ret = 0.0, now = 1, tt = x * x, k = 1;
    for(int i = 0; i < 1000; i++) {
        ret += now / k;
        now *= (-tt);
        k *= (2 * i + 1) * (2 * i + 2);
    }
    return ret;
}
int main()
{
    //printf("%.20f %.20f\n", (double)mycos(PI / 3), cos(PI / 3));
	int d,t;
	ldouble x=0,y=0;
    int dir = 0;
	while(scanf("%d%*c%d", &d, &t) &&d!=0&&t!=0)			//霎灘?0,0扈捺據
	{
	    while(dir >= 360) dir -= 360;
	    while(dir < 0) dir += 360;
		x -= d * sin(((ldouble)dir) * PI / 180.0);						//隶。邂?		y += d * cos(((ldouble)dir) * PI / 180.0);
	    dir -= t;
	}
    long long ox, oy;
    ox = x, oy = y;
	printf("%lld\n%lld\n", ox, oy);					//霎灘?

	return 0;
}