#include <iostream>
#include <cmath>

int main()
{
    double x = 0.0, y = 0.0;
    const double pi = acos(-1.0);

    int prev_deg = 90;
    while (true) {
        int dist, deg;
        char comma;
        std::cin >> dist >> comma >> deg;
        if (dist == 0 && deg == 0) break;

        x += dist * cos(prev_deg * pi / 180);
        y += dist * sin(prev_deg * pi / 180);

        prev_deg -= deg;
    }

    std::cout << (int)x << "\n" << (int)y << std::endl;
}