#include <iostream>
#define _USE_MATH_DEFINES
#include <cmath>

using namespace std;

//0016
int main(){
	const double PI = M_PI;
	double x=0.0, y=0.0;
	int deg;
	int acc=90;
	int f=0;

	while(1){
		scanf("%d,%d", &f, &deg);
		if(!f && !deg)break;

		double rad = (double)acc/180*PI;
		x += f * cos(rad);
		y += f * sin(rad);
		acc = (acc - deg);

	}

	cout << (int)x << endl;
	cout << (int)y << endl;
	return 0;
}