#include <iostream>
#include <algorithm>
#include <complex>
#include <string>
#include <sstream>
#include <cmath>
using namespace std;
typedef complex<double> P;

const double pi = acos(-1);

int main() {
  string s;
  double rad = pi/2.0;
  P pos(0,0);
  while(cin >> s) {
    replace(s.begin(), s.end(), ',', ' ');
    stringstream ss(s);
    double n;
    double d;
    ss >> n >> d;
    if(n == 0.0 && d == 0.0) break;
    d = -d*pi/180.0;
    pos += n*P(cos(rad),sin(rad));
    rad += d;
  }
  cout << (int)pos.real() << endl;
  cout << (int)pos.imag() << endl;
  return 0;
}