Go: package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextFloat64() (float64, error) {
	return strconv.ParseFloat(nextString(), 64)
}

func main() {
	scanner.Split(bufio.ScanWords)

	x, y := 0.0, 0.0
	rotate := 90.0

	for {
		line := nextString()
		if line == "0,0" {
			break
		}

		numbers := strings.Split(line, ",")
		di, _ := strconv.ParseFloat(numbers[0], 64)
		ai, _ := strconv.ParseFloat(numbers[1], 64)

		rotateRadian := math.Pi * rotate / 180.0
		x += di * math.Cos(rotateRadian)
		y += di * math.Sin(rotateRadian)

		rotate -= ai

		// fmt.Println(x, y)
	}

	fmt.Println(int(x))
	fmt.Println(int(y))
}

C++: #include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
  double x = 0,y = 0,dis,ang = 90,a;
  for(;;){
    scanf("%lf,%lf",&dis,&a);
    if(dis == 0 && a == 0){break;}
    x+=dis*cos(M_PI*ang/180.0);
    y+=dis*sin(M_PI*ang/180.0);
    ang-=a;
  }
  printf("%.0lf\n%.0lf\n",x,y);
  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

#define PI 3.1415926535898
#define AG (PI/180.0)

int main() {
	int rad, adv;
	double x=0.0, y=0.0,dir=0.0;
	while (scanf("%d%*c%d",&adv,&rad)&&adv!=0.0&&rad!=0.0) {
		x += (double)adv*sin(dir*AG);
		y += (double)adv*cos(dir*AG);
		dir += (double)rad;
	}
	printf("%d\n%d\n",(int)x,(int)y);
}

C++: #include<stdio.h>
#include<math.h>
int main()
{
	int k,h,f;
	double p=3.141592653589,tt,yk,x=0,y=0,r,mk=0;
	while(1){
		scanf("%d,%d",&h,&k);
		if(h==0&&k==0){
			break;
		}
		mk+=k;
		if(mk>=360){
			mk-=360;
		}
		if(mk<=360){
			mk+=360;
		}
		if(mk>=0){
			f=1;
		}else{
			f=0;
		}
		k=fabs(k);
		r=((90-mk)*p)/180;
		yk=cos(r)*h;
		tt=sin(r)*h;
		if(f){
			x+=yk;
		}else{
			x-=yk;
		}
		y+=tt;
	}
	printf("%d,%d\n",(int)x,(int)y);
	return 0;
}

C++: #include<stdio.h>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#define pi 3.14159
using namespace std;

int main() {
	double ang = pi / 2;
	double X = 0, Y = 0;
	while(1) {
		int x, y;
		scanf("%d, %d",&x, &y);
		if (x == 0 && y == 0) break;
		X = X + x * cos(ang);
		Y = Y + x * sin(ang);
		ang = ang - y * pi / 180;
	}
	printf("%d\n%d\n", (int)X, (int)Y);

	return 0;
}

C++: float x,y,z;d;main(r){for(;~scanf("%d,%d",&r,&d)?y+=r*cos(z),x-=r*sin(z),z-=d/57.3,1:!printf("%d\n%d\n",d=x,r=y););}

C++: //Aizu - 0016 : Treasure Hunt
#include<stdio.h>
#include<math.h>

const double PAI = acos(-1.0);
//#define PAI 3.1415926

int main()
{
	int d,t,ang=0;
	double x=0,y=0;

	while(scanf("%d%*c%d",&d,&t)&&(!(d==0&&t==0)))			//霎灘?0,0扈捺據
	{
		x+=d*sin(1.0*PAI*ang/180.0);						//隶。邂?		y+=d*cos(1.0*PAI*ang/180.0);
		ang+=t;
	}

	printf("%d\n%d\n",(int)x,(int)y);					//霎灘?

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int flr(double x){
	if(x<0)	return ceil(x);
	else 	return floor(x);
}
int main(){
	double x=0,y=0;
	int arg=90;
	while(true){
		int d,a;	scanf("%d,%d",&d,&a);
		if(d==0&&a==0)	break;
		double args=(arg)/180.0*M_PI;
		x+=d*cos(args);	y+=d*sin(args);
		arg-=a;
	}
	printf("%d\n",flr(x));
	printf("%d\n",flr(y));
	return 0;
}

C++: #include <cstdio>
#include <cmath>

#define PI 3.1416

using namespace std;

int main(){
  int d;
  float mt=90.0*PI/180;
  float t,x,y;
  x=y=0.0;
  while(1){
    scanf("%d,%f",&d,&t);
    if(d==0&&t==0) break;
    x+=d*cos(mt);
    y+=d*sin(mt);
    mt+=-t*PI/180;
  }
  if(x<0) x+=1;
  if(y<0) y+=1;
  printf("%.0f\n%.0f",floor(x),floor(y));
  return 0;
}

C++: #include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

int main(int argc, char *argv[]) {
  int a, b;
  double x, y, angle;

  x = y = angle = 0.0;

  while (true) {
    scanf("%d,%d", &a, &b);
    if (a == 0 && b == 0)
      break;
    y += a * cos(angle / 180 * M_PI);
    x += a * sin(angle / 180 * M_PI);
    angle += b;
  }

  cout << (int)x << endl;
  cout << (int)y << endl;
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  double x=0,y=0,s=90;
  int a,b;
  while(scanf("%d,%d",&a,&b),a){
    x+=a*cos(s*M_PI/180);
    y+=a*sin(s*M_PI/180);
    s-=b;
  }
  cout<<(int)x<<endl;
  cout<<(int)y<<endl;
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int main(void){
	int A, B;
	double x=0, y=0, angle=3.14159265/2;
	for(;;){
		scanf("%d,%d", &A, &B);
		if(A==0 && B==0) break;
		x+=cos(angle)*A;
		y+=sin(angle)*A;
		angle += B*3.14159265/180;
	}
	printf("%d\n%d\n", (int)x, (int)y);
	return 0;
}

C++: //include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-12;
const double INF = 1e12;


int main(){
	double a,b;char c;
	double x=0,y=0,sita=0;
	while(cin>>a>>c>>b){
		
		if(a==0&&b==0)break;
		x+=cos((sita/180.0)*M_PI)*a;
		y+=sin((sita/180.0)*M_PI)*a;
		sita+=b;
		
		
	}
	cout<<(int)y<<endl;
	cout<<(int)x<<endl;
	return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<cmath>

using namespace std;

#define PI 3.141592654

struct point{
	double x;
	double y;
};

struct input{
	double length;
	double theta;
};

double get_radian( double theta_deg );
ostream& operator << ( ostream& s , point& p );

int main(void)
{
	input data;
	point goal = { 0.0 , 0.0 };
	double theta = 90;

	while(1)
	{
		scanf("%lf , %lf" , &data.length , &data.theta );
		if( data.length == 0 && data.theta == 0 ) break;

		goal.x += data.length * cos( get_radian(theta) );
		goal.y += data.length * sin( get_radian(theta) );

		theta -= data.theta;
	}
	cout << goal;
}

double get_radian( double theta_deg )
{
	return theta_deg*PI/180;
}

ostream& operator << ( ostream& s , point& p )
{
	return s << int(p.x) << endl << int(p.y) << endl;
}

C++: #include <iostream>
#include <cmath>
using namespace std;

int main()
{
	double PI = atan(1.0)*4;
	cout << PI << endl;
	double a = 90;
	double x=0, y=0;

	while ( true )
	{
		char c;
		int r,t;
		cin>>r>>c>>t;
		if ( r==0 && t==0 )
			break;

		x += r*cos(a/360.*2*PI);
		y += r*sin(a/360.*2*PI);
		a -= t;
	}

	cout << (int)x << endl;
	cout << (int)y << endl;
	return 0;
}