#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <stack>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
using namespace std;

int main(){
    int d, a, pa = 0;
    double x = 0, y = 0;
    while (true){
        scanf("%d,%d", &d, &a);
        if (d == 0 && a == 0) break;
        x += d * sin(pa*M_PI/180);
        y += d * cos(pa*M_PI/180);
        pa += a;
    }
    int ax = x, ay = y;
    printf("%d\n%d\n", ax, ay);
}
