#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <stdio.h>
 
using namespace std;

//-------------------------------------------------------------------------
// geometric library
 
namespace geometry {
 
struct point {
    double x;
    double y;
};
 
struct circle {
    point center;
    double radius;
};
 
struct line { // ax + by + c = 0
    double a;
    double b;
    double c;
};
 
std::istream& operator >> (std::istream& is, point& p)
{
    is >> p.x >> p.y;
    return is;
}
 
bool operator == (const point& p1, const point& p2)
{
    return p1.x == p2.x && p1.y == p2.y;
}
 
///! 2点の距離
double get_distance(const point& p1, const point& p2)
{
    return sqrt(pow(p1.x - p2.x, 2) + pow(p1.y - p2.y, 2));
}
 
///! 2直線の交点
bool get_crosspoint(const line& l1, const line& l2, point *result)
{
    double denominator = l1.a * l2.b - l1.b * l2.a;
    if (denominator == 0) {
        return false;
    }
    result->x = (l1.b * l2.c - l2.b * l1.c) / denominator;
    result->y = (l2.a * l1.c - l1.a * l2.c) / denominator;
    return true;
}
 
///! 2点の垂直2等分線
bool get_bisector(const point& p1, const point& p2, line *result)
{
    if (p1 == p2) {
        return false;
    }
    result->a = 2 * (p1.x - p2.x);
    result->b = 2 * (p1.y - p2.y);
    result->c = -(p1.y - p2.y) * (p1.y + p2.y) - (p1.x - p2.x) * (p1.x + p2.x);
    return true;
}
 
///! 外接円を求める
bool get_circum_circle(const point& p1, const point& p2, const point& p3, circle *result)
{
    double a = get_distance(p1, p2);
    double b = get_distance(p2, p3);
    double c = get_distance(p3, p1);
 
    // 半径の公式
    result->radius = a * b * c / sqrt((a + b + c) * (-a + b + c) * (a - b + c) * (a + b - c));
 
    line line_p1p2;
    line line_p2p3;
 
    // 頂点の垂直2等分線の交点が外心
    return get_bisector(p1, p2, &line_p1p2) &&
           get_bisector(p2, p3, &line_p2p3) &&
           get_crosspoint(line_p1p2, line_p2p3, &result->center);
}
 
} // namespace geometry

using namespace geometry; 


int main(void)
{
	int steps, dtheta;
	char comma;
	double theta;
	point p;

	p.x = p.y = 0.0;
	theta = 90.0;

	while (cin >> steps >> comma >> dtheta) {
		assert(comma == ',');

		if (steps == 0 && dtheta == 0) {
			break;
		}

		p.x += steps * cos(theta * M_PI / 180.0);
		p.y += steps * sin(theta * M_PI / 180.0);
		theta -= dtheta; // 正の数は右に回る
	}

	cout << (int)p.x << endl << (int)p.y << endl;
}