#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

double dot(P a,P b){return real(conj(a)*b);};
double cross(P a,P b){return imag(conj(a)*b);};

int main(){
  int a,b;
  P o(0,0);
  double nowang = 3.141592653589793238 / 2.0;
  P I(0,1);
  while(~scanf("%d,%d",&a,&b)){
    if(a==0 && b==0)break;
    double len = a;
    double ang = (double)b / 180.0 * 3.141592653589793238;
    ang *= -1.0;
    P angvec = exp(I*nowang);
    o += angvec * len;
    nowang += ang;
  }
  cout<<(int)real(o)<<endl;
  cout<<(int)imag(o)<<endl;
  return 0;
}