#include <cstdio>
#include <algorithm>
#include <complex>

using namespace std;

using Point=complex<double>;

static const double PI=3.141592653589793;

int main() {
    Point arg=polar(1.0, PI/2);
    Point target=0+0i;
    while (true) {
        double d, a;
        scanf("%lf, %lf", &d, &a);

        if (d == 0.0 && a == 0.0)
            break;

        target += d*arg;
        arg *= polar(1.0, -a*PI/180);
    }

    int x=target.real(), y=target.imag();

    printf("%d\n", x);
    printf("%d\n", y);
    return 0;
}