#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <queue>
#include <vector>

using namespace std;

const double PI = atan(1)*4;

int main() {
  int r, d;
  double x = 0, y = 0, t = PI / 2.0;
  for (;;) {
    scanf("%d,%d", &r, &d);
    if (!r && !d) {
      printf("%d\n%d\n", int(x), int(y));
      return 0;
    }
    x += double(r) * cos(t);
    y += double(r) * sin(t);
    t -= double(d) * PI / 180.0;
  }
}