#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
#define int long long
signed main(){
        int a,b;
        float x=0,y=0;
        int d=90;
        while( scanf("%lld,%lld", &a, &b) != EOF ){
                if(a==0&&b==0) break;
                x+=a*cos(d/180.0*M_PI);
                y+=a*sin(d/180.0*M_PI);
                d-=b;
        }
        printf("%.0f\n%.0f\n",x,y);
        return 0;
}