#include<bits/stdc++.h>

#define PI 3.141592653589793

using namespace std;

int main(){
    int d, a, ba=90;
    double x=0,y=0;
    while(scanf("%d,%d",&d,&a), d != 0 || a != 0){
        x += d * cos(ba * PI / 180.0);
        y += d * sin(ba * PI / 180.0);
        ba -= a;
    }
    cout << (x > 0 ? floor(x) : ceil(x)) << endl;
    cout << (y > 0 ? floor(y) : ceil(y)) << endl;

    return 0;
}
