#include<stdio.h>
#include<math.h>
int main()
{
double N,P;
double x,y;

x=0;y=0;
while(1)
{
scanf("%lf,%lf",&N,&P);
if((int)N==0&&(int)P==0)break;
double p;
if(0<=(int)P&&(int)P<90){p=P*3.141592/180;x+=N*sin(p);y+=N*cos(p);}
else if(90<=(int)P&&(int)P<=180){p=(180-P)*3.141592/180;x+=N*sin(p);y-=N*cos(p);}
else if(0>(int)P&&(int)P>=-90){p=(-1*P)*3.141592/180;x-=N*sin(p);y+=N*cos(p);}
else if(-90>(int)P&&(int)P>=-180){p=(180+P)*3.141592/180;x-=N*sin(p);y-=N*cos(p);}
}
int X,Y;
X=(int)x;Y=(int)y;
printf("%d\n",X);printf("%d\n",Y);

return 0;
}