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 <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(c,i) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	const double EPS=1e-6;
	double x=0,y=0;
	double dir=M_PI/2;
	for(int a,d;scanf("%d,%d",&a,&d),a|d;){
		x+=a*cos(dir);
		y+=a*sin(dir);
		dir-=d*M_PI/180;
	}
	printf("%d %d\n",int(x+EPS),int(y+EPS));
	
	return 0;
}

C++: #include<stdio.h>
#include<math.h>
#define M_PI 3.14159265358979

int main(void)
{
	int i=0,a,b,k=90;
	double x=0,y=0;

	while(i == 0)
	{
		scanf("%d,%d",&a,&b);

		if(a == 0 && b == 0)break;

		x += cos(k * M_PI / 180)*a;
		y += sin(k * M_PI / 180)*a;
		k -= b;
	}
  printf("%d\n",(int)x);
  printf("%d\n",(int)y);

  return 0;
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define EXIST(v,i) (find(all(v), i) != (v).end())
#define ERASE(v,i) (v).erase(remove(all(v), i), (v).end())
#define INDEX(v,i) (find(all(v), i) - (v).begin())
#define rep(i,n) for(int i = 0; i < (int)n; ++i)
#define debug(x) cerr << #x << " = " << (x) << endl;

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();}

const int INF = 100000000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;

int main() {
	double cx = 0, cy = 0;
	double angle = 90;
	for(int l, r; scanf("%d,%d", &l, &r) && l && r;) {
		double rad = angle * PI / 180.0;
		cx += l * cos(rad);
		cy += l * sin(rad);
		angle -= r;
#if 0
		cout << "before" << endl;
		cout << rad << endl;
		cout << cx << endl;
		cout << cy << endl;
		cout << "after" << endl;
#endif
	}
	printf("%d\n%d\n", (int)cx, (int)cy);
	return 0;
}

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

int main() {
  double pi=3.14159265358979;
  double x=0, y=0, r=-pi/2;

  while(1) {
    int z,nr;
    scanf("%d%*c%d",&z,&nr);
    if(z==0 && nr==0) break;

    x += z*cos(r);
    y += z*sin(r);
    r -= nr*pi/180;
  }
  cout << -(int)x << endl << -(int)y << endl;
  return 0;
}

C++: /*Filename: aoj0016.cpp
 *Author: Mushiyo
 */

#include <stdio.h>
#include <cmath>

using namespace std;

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

	while (scanf("%d, %d", &d, &t) == 2) {
		if (d == 0 && t == 0) {
			break;
		}

		double dx = d * cos(direction * M_PI / 180.0);
		double dy = d * sin(direction * M_PI / 180.0);

		x += dx;
		y += dy;

		direction -= t;
		direction %= 360;
		if (direction < 0) {
			direction += 360;
		}
	}

	printf("%.0f\n", x);
	printf("%.0f\n", y);

	return 0;
}

C++: #include<iostream>
#include<cmath>
using namespace std;
int main(){
	double nx=0,ny=0,x,y,ro=90;
	while(true){
		cin>>x;cin.ignore();cin>>y;	
		if(x==0&&y==0)break;
		ny+=x*sin(ro/180*M_PI);
		nx+=x*cos(ro/180*M_PI);
		ro-=y;
		//if(ro<0)ro=360-abs(ro);
		//cout<<nx<<" "<<ny<<endl;
	}
	cout<<(int)nx<<endl<<(int)ny<<endl;
	return 0;
}