#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <complex>

using namespace std;

const double PI=3.14159265;

int main()
{
	int r,t,T;
	complex<double> ans(0.0,0.0);

	T=90;

	while(scanf("%d,%d",&r,&t)>0){
		ans+=polar((double)r,(double)T*PI/180.0);
		T-=t;
	}
	
	cout<<(int)ans.real()<<endl<<(int)ans.imag()<<endl;

	return 0;

}