#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <string.h>
#include <stack>
#include <cmath>
using namespace std;

#define ISEQ(c) (c).begin(), (c).end()
typedef long long ll;

int main() {
  const double pi = acos(-1);
  double arg = pi / 2;
  double x = 0, y = 0;
  while (true) {
    double a, b;
    scanf("%lf,%lf", &a, &b);
    if (a == 0 and b == 0) break;
    x += a * cos(arg);
    y += a * sin(arg);
    arg += -2 * pi * b / 360;
  }
  printf("%d\n%d\n", (int)x, (int)y);
}