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

int main(){
	double x,y,dx,dy,pi;
	int d,rad,prad;
	char camma;
	x=y=0;
	pi=3.141592;
	while(cin>>d>>camma>>rad){
		if(d==0 && rad==0)break;
		dx=d*cos((rad+prad)*pi/180);
		dy=d*sin((rad+prad)*pi/180);
		x+=dx;
		y+=dy;
		prad=rad;
	}
	cout<<(int)x<<endl;
	cout<<(int)y<<endl;
	return 0;
}