#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

template <typename T, int N>
int ArraySize(const T(&)[N]) {
    return N;
}


int main() {
    constexpr double Pi = 3.1415926535;

    long double x {}, y {}, radianAngle {Pi / 2.0};
    
    char c;

    for(int steps, rotate, currentRotation{90}; cin >> steps >> c >> rotate;) {
        if(steps == 0 && rotate == 0) break;


        x += steps * cos(radianAngle);
        y += steps * sin(radianAngle);

        currentRotation += -rotate < 0 ? -rotate : 360 - rotate;
        radianAngle = 2 * Pi * currentRotation / 360;

    }

    

    std::cout << static_cast<int>(x) << '\n' << static_cast<int>(y) << endl;

    return 0;
}