#include <iostream>
#include <math.h>
#include <cstdio>
#include <stdio.h>
#include <cmath>
using namespace std;
int main(){
	double x=0,y=0,c=0;
	int a,b;
	while(scanf("%d,%d",&a,&b) != EOF){
		if(a==0 && b==0) break;
		x += (double)a*(double)sin(c*6.0*asin(0.5)/180.0);
		y += (double)a*(double)cos(c*6.0*asin(0.5)/180.0);
		c += (double)b;
		if(c>(double)180){
			c -= (double)360;
		}
		if(c<(double)-180){
			c += (double)360;
		}
	}
	cout<<(int)x<<endl<<(int)y<<endl;
	return 0;
}