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

int main(){
	double x = 0;
	double y = 0;
	int angle = 90;
	int d, a;
	while(scanf("%d,%d", &d, &a)){
		if(d == 0 && a == 0){
			break;
		}
		x += d*cos(angle*M_PI/180);
		y += d*sin(angle*M_PI/180);
		angle += a;
		if(angle >= 360){
			angle %= 360;
		}else if(angle <= 0){
			angle += 360;
		}
	}
	cout << (int)x << endl;
	cout << (int)y << endl;
	return 0;
}