#include <iostream>
#include <cmath>
#define PI 3.14159265359
using namespace std;

int main(){
	double x = 0;
	double y = 0;
	double theta = PI/2, kyori, yobi;
	for(int i = 0; i < 1000; i++){
		char trash;
		cin >> kyori >> trash >> yobi;
		if(kyori == 0 && yobi == 0){
			break;
		}
		yobi = yobi*PI/180;
		x = x + kyori*cos(PI-theta);
		y = y + kyori*sin(theta);
		theta = theta+yobi;
	}
	cout << (int)x << endl << (int)y << endl;
}