#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
	int dir=0, rad, adv;
	double x=0.0, y=0.0;
	while (scanf("%d, %d\n",adv,rad)) {
		if (adv==0&&rad==0) break;
		dir += rad;
		x += cos(dir)*adv;
		y += sin(dir)*adv;
	}
	int X = (int)x;
	int Y = (int)y;
	printf("%d\n%d",x,y);
}