#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
  int d, t;
  double x, y, theta;

  x = 0;
  y = 0;
  theta = 90;
  while (1) {
    scanf("%d,%d", &d, &t);
    if (!d && !t) break;
    x += d*cos(theta/180.0*M_PI);
    y += d*sin(theta/180.0*M_PI);
    theta -= t;
  }
  cout << ((x>=0.0) ? (int)floor(x) : (int)ceil(x)) << endl;
  cout << ((y>=0.0) ? (int)floor(y) : (int)ceil(y))<< endl;

  return 0;
}