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

using namespace std;

int main() {
    int dest = 90;
    double x = 0;
    double y = 0;
    int d, t;

    while(scanf("%d,%d", &d, &t), d) {
        double rad = dest * M_PI / 180.0;
        x += d * cos(rad);
        y += d * sin(rad);
        dest -= t;
    }
    cout << (int) x << endl;
    cout << (int) y << endl;
}