#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main()
{
	double len, angle;
	double sum_ang = 90.0; // start
	double x = 0.0, y = 0.0;

	// ang(+) -> right 
	while (scanf("%lf,%lf", &len, &angle), len != 0.0 && angle != 0.0){
		x += len * cos(M_PI * sum_ang / 180.0);
		y += len * sin(M_PI * sum_ang / 180.0);

		sum_ang -= angle;
	}

	printf("%d\n", (int)x);
	printf("%d\n", (int)y);

	return (0);
}