#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int d, a;
    double x = 0, y = 0;

    int angle = 90;
    while (true)
    {
        scanf("%d,%d", &d, &a);
        if (d == 0 && a == 0)
            break;
        x = x + d * cos(angle * M_PI / 180);
        y = y + d * sin(angle * M_PI / 180);

        angle -= a;
    }
    cout << (int)x << endl;
    cout << (int)y << endl;
    return 0;
}
