#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

int main(void)
{
	const double PI = 6 * asin(0.5);
	double angle = 0.0;
	double x = 0.0, y = 0.0;

	while(1) {
		int dist, theta;
		scanf("%d,%d", &dist, &theta);

		if(dist == 0 && theta == 0) break;

		x += dist * sin(angle);
		y += dist * cos(angle);
		angle += (theta * PI) / 180;
	}

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