#include <bits/stdc++.h>

using namespace std;

int main(){
    double x, y;
    int n, m, r;
    while(scanf("%d,%d", &n, &m), n+m){
        x += n*sin(r*M_PI/180.0);
        y += n*cos(r*M_PI/180.0);
        r += m;
    }
    cout << (int)x << "\n" << (int)y << endl;
}