#define _USE_MATH_DEFINES
#include <complex>
#include <cmath>
#include <cstdio>

using namespace std;

int main()
{
	double current_angle_in_degree = 0;
	complex<double> current_position = 0;

	int input_distance = 0, input_angle_in_degree = 0;
	while (scanf("%d,%d", &input_distance, &input_angle_in_degree) == 2) {
		if (input_distance == 0 && input_angle_in_degree == 0) {
			break;
		}
		double angle_in_radian = current_angle_in_degree * M_PI / 180.0;
		current_position += static_cast<double>(input_distance)
			* complex<double>(cos(angle_in_radian), sin(angle_in_radian));
		current_angle_in_degree += input_angle_in_degree;
	}

	printf("%d\n%d\n",
		 static_cast<int>(current_position.imag()),
		 static_cast<int>(current_position.real()));

	return 0;
}