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


int main(int argc, char *argv[]){
	double x=0,y=0,th=-1,d=0,dir=90;
	while(!(d==0 && th==0)){

		cin>>d; cin.ignore();cin>>th;
		x+=d*cos(dir*M_PI/180);
		y+=d*sin(dir*M_PI/180);
		
		dir-=th;

	}
	cout<<(int)x<<endl<<(int)y<<endl;
	return 0;
}