#include <stdio.h>
#include <math.h>

void walk(double current_point[2], int r, int sum_theta) {
	double pi = 3.14159265358979; 
	double rad = ((double)sum_theta / 180) * pi;
	current_point[0] += r * sin(rad);
	current_point[1] += r * cos(rad);
}

int main() {
	int r;
	int theta;
	int sum_theta = 0;
	double current_point[2] = {0, 0};

	do {
		scanf("%d,%d", &r, &theta);

		walk(current_point, r, sum_theta);
		sum_theta += theta;
	} while(r || theta);

	printf("%d\n", (int)current_point[0]);
	printf("%d\n", (int)current_point[1]);

	return 0;
}