#include <iostream>
#include <cmath>

#define PI acos(-1.0)

using namespace std;

int main(){
    int d, r, t = 90;
    double x = 0, y = 0;
    while(scanf("%d,%d", &d, &r), d || r){
	x += d * cos(1.0*t / 180 * PI);
	y += d * sin(1.0*t / 180 * PI);
	t -= r;
    }
    cout << (int)x << endl << (int)y << endl;
    return 0;
}