#include<iostream>
#include<sstream>
#include<fstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;

int main(){
	double tot = 0,alfa = 90,x=0,y=0;
	int m,t;
	while(scanf("%d,%d",&m,&t),m || t){
		//alfa += t;
		x += m*cos(alfa*3.1416/180.0);
		y += m*sin(alfa*3.1416/180.0);
		alfa -= t;
	}
	x = (int)x;
	y = (int)y;
	cout<<x<<endl;
	cout<<y<<endl;
	return 0;
}