#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

const double PI = acos(-1.0);

int main(){
    int d,r,t = 0;
    char c;
    double x = 0,y = 0;
    while(scanf("%lf,%lf",&d,&r) && (d || r)){
        x += d * sin((t) * PI / 180.0);
        y += d * cos((t) * PI / 180.0);
        t += r;
    }
    printf("%d\n%d\n",(int)x,(int)y);
    return 0;
}
