#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>

#define rep(i, j) FOR(i, 0, j)
#define FOR(i, j, k) for(int i = j; i < k; ++i)

using namespace std;

int main(){
  double d, t, x, y, n;
  x = y  = 0;
  n = 90;
  while(scanf("%lf,%lf", &d, &t) && d && t){
    x += d * sin(n * M_PI / 180);
    y += d * cos(n * M_PI / 180);
    n -= t;

  }
  printf("%d\n%d\n", (int)y, (int)x);
  return 0;
}