#include <bits/stdc++.h>

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int d, a;
  double x = 0, y = 0, degree = 90;
  char c;
  while (cin >> d >> c >> a, d != 0 || a != 0) {
    x += d * cos(degree / 180 * M_PI);
    y += d * sin(degree / 180 * M_PI);
    degree -= a;
  }
  cout << (int)x << endl;
  cout << (int)y << endl;
}
