#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


constexpr long double pi = acos(-1L);

V<string> split(const string& s, char c) {
  V<string> res;
  stringstream ss(s);
  string t;
  while (getline(ss, t, c)) res.push_back(t);
  return res;
}

int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  long double x = 0, y = 0;
  int th = 90;
  string s;
  while (getline(cin, s)) {
    auto ss = split(s, ',');
    int d = stoi(ss[0]), a = stoi(ss[1]);
    if (d == 0) break;
    x += d * cos(th * pi / 180);
    y += d * sin(th * pi / 180);
    th -= a;
  }
  cout << static_cast<int>(x) << ' ' << static_cast<int>(y) << '\n';
}
