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

#define M_PI 3.14159265358979

int main(void)
{
    int step, dig;
    double x, y, angle;

    x = 0;
    y = 0;
    angle = 0;

    while (1){
        scanf("%d,%d", &step, &dig);

        if (step == 0 && dig == 0){
            break;
        }

        x += (double)step * sin(angle * (M_PI / 180));
        y += (double)step * cos(angle * (M_PI / 180));
        angle += (double)dig;
    }

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

    return 0;
}