import std.stdio;
import std.conv;
import std.algorithm;
import std.string;
import std.file;
import std.math;

int main() {
	float x, y;  // x to east, y to north
	float dir; // direction by radian, 0.0 = east, pi/2 = north
	
	x = 0.0, y = 0.0;
	dir = PI/2;
	
	string l;
	while((l = readln().split[0], l.length)){
		if(!l.split.length || l.split(",")[0] == "0" && l.split(",")[1] == "0") break;
		
		float a, b;
		a = to!float(l.split(",")[0]), b = to!float(l.split(",")[1]);
		
		x += a * cos(dir);
		y += a * sin(dir);
		
		dir += -b / 180 * PI;
		}
	printf("%d\n", to!int(x));
	printf("%d\n", to!int(y));
	return 0;
	}