#include <iostream>
#include <cmath>

const double PI = 4 * atan(1);
int naturalPart(const double r){
    if(r>0) return floor(r);
    else    return ceil(r);
}

int main(){
    double x = 0, y = 0;
    int stride, dir = 90, rot;
    while(1){
        std::cin >> stride;
        x += stride * cos(dir * PI / 180);
        y += stride * sin(dir * PI / 180);
        std::cin.ignore() >> rot;
        if(!stride && !rot)
            break;
        dir -= rot;
    }
    
    std::cout << naturalPart(x) << '\n' << naturalPart(y) << std::endl;
    return 0;
}