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

int main(){
	int ad, angle, angle_sum = 0;
	double x = 0, y = 0;
	while(1){
		scanf("%d,%d", &ad, &angle);
		if(ad == 0 && angle == 0) break;
		x += (double)ad * sin(angle_sum * M_PI / 180.0);
		y += (double)ad * cos(angle_sum * M_PI / 180.0);
		angle_sum += angle;
	}
	cout << (int)x << endl << (int)y << endl;
	return 0;
}