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

int main(void)
{
	double distance, theta, N = 0, E = 0, sum=90;
	int i, j;
	char con;

	while (cin >> distance >> con >> theta)
	{
		if (distance == 0 && theta == 0) break;
		N += sin((sum * M_PI) / 180) * distance;
		E += cos((sum * M_PI) / 180) * distance;
		sum -= theta;
	}
	cout << (int)E << endl << (int)N << endl;
	return 0;
}
