#include <cstdio>
#include <cmath>

int main(void) {
    double x = 0, y = 0, c = 0;
    int a, b;
    while (true) {
        scanf("%d,%d", &a, &b);
        if (a == 0 && b == 0) break;
        x += a * sin(c);
        y += a * cos(c);
        c += (b / 180.0) * M_PI;
    }
    printf("%d\n%d\n", (int)x, (int)y);
    return 0;
}