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 <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
#define ALL(a)  (a).begin(),(a).end()
#define REP(i,n) for(int i=0;i<(n);++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define dump(x) cerr << "  (L" << __LINE__ << ") " << #x << " = " << (x) << endl;
#define dumpv(x) cerr << "  (L" << __LINE__ << ") " << #x << " = "; REP(q,(x).size()) cerr << (x)[q] << " "; cerr << endl;
template<typename T1, typename T2>
ostream& operator<<(ostream& s, const pair<T1, T2>& d) {return s << "(" << d.first << "," << d.second << ")";}


int main() {
  double x = 0.0, y = 0.0;
  double angle = 90;

  while (true) {
    int a, b; scanf("%d,%d", &a, &b); 
    if (a == 0 && b == 0) break;

    double theta = PI * angle / 180.0;
    x += a * cos(theta);
    y += a * sin(theta);
    angle -= b;
  }

  printf("%d\n%d\n", (int)x, (int)y);
}

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

int main() {
	double x=0, y=0, a, b, now = 90;
	char c;
	while (cin >> a >> c >> b, a || b) {
		x += a * cos(M_PI * now / 180);
		y += a * sin(M_PI * now / 180);
		now = now - b;
	}
	if (x >= 0) x = floor(x);
	else if (x < 0) x = ceil(x);
	if (y >= 0) y = floor(y);
	else if (y < 0) y = ceil(y);
		cout << x << endl;
		cout << y << endl;
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <stack>
using namespace std;


double rad(int degree){
	return (M_PI*degree) / 180;
}


int main(){
	double x = 0, y = 0;
	int d, dir = 90, a;
	char comma;

	while (cin >> d >> comma >> a, d || a){
		x += d * cos(rad(dir));
		y += d * sin(rad(dir));
		dir -= a;
	}

	cout << (int)x << endl;
	cout << (int)y << endl;

	return 0;
}

C++: #define _USE_MATH_DEFINES
#include<cmath>
#include<iostream>
int main()
{
	double x = 0, y = 0;
	int a = 90;
	while (true)
	{
		int di, ai;
		char temp;
		std::cin >> di >> temp >> ai;
		if (di == 0 && ai == 0)
		{
			break;
		}
		x += di * cos(a * M_PI / 180);
		y += di * sin(a * M_PI / 180);
		a -= ai;
	}
	std::cout << static_cast<int>(floor(x)) << std::endl;
	std::cout << static_cast<int>(floor(y)) << std::endl;
	return 0;
}

C++: 
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#define __typeof__ decltype
#endif

#define ITER(c)         __typeof__((c).begin())
#define FOREACH(it, c)  for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)        __typeof__((c).rbegin())
#define RFOREACH(it, c) for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)       REPEAT(i, 0, n)
#define REPEAT(i, k, n) for (int i = (k); i < (n); ++i)
#define REVREP(i, n)    for (int i = ((n)-1); i >= 0; --i)
#define ESIZEOF(A)      (sizeof(A)/sizeof((A)[0]))
#define MIN(p1,p2)      (((p1)<(p2))?(p1):(p2))
#define MAX(p1,p2)      (((p1)>(p2))?(p1):(p2))
#define CIN_NO_SYNC     do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)

#define X real()
#define Y imag()
typedef double D;
typedef complex<double>P;

D inprd(const P &a, const P &b){ return (conj(a) * b).X; }
D outprd(const P &a, const P &b){ return (conj(a) * b).Y; }
P circum_center(const P &a, const P &b, const P &c){
    P bc = c - b, ca = a - c, ab = b - a;
    return (a + b - (inprd(bc, ca) / outprd(ab, bc)) * ab * P(0,1)) / 2.0;
}
D sign(D d){ return (d<0)?-1:d>0?1:0; }

int main(void){
    CIN_NO_SYNC;
    int r, d; char c;
    P deg(0,1);
    P pts(0,0);
    while(cin >> r >> c >> d){
        pts += deg * P(r, 0);
        deg *= polar(1.0, M_PI*-d/180);
    }
    printf("%d\n%d\n", (int)pts.X, (int)pts.Y);
    return 0;
}

C++: #include <string>
#include <vector>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<sstream>
#include<functional>
#include<map>
#include<set>
#include<cmath>

using namespace std;

int main(){

	int a,b; int c=90; double x=0; double y=0;
	while(true){
	scanf("%d %d",&a,&b);
	if(a==0 && b==0) break;
	x+=a*cos(c*3.141592/180);
	y+=a*sin(c*3.141592/180);
	c-=b;

	}

	printf("%d\n%d\n",(int)x,(int)y);

	return 0;

    }

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

int main()
{
	int x=1,y=1,k=0,h=0;
	double r=90;
	for(;x!=0||y!=0;)
	{
		scanf("%d,%d",&x,&y);
		k+=x*sin(r*M_PI/180);
		h+=x*cos(r*M_PI/180);
		r-=y;
	}
	printf("%d\n%d\n",h,k);
	return 0;
}

C++: #include <stdio.h>
#include <math.h>

#define M_PI 3.14159265358979323846

double dtor(int d){
	return d / 180.0 * M_PI;
}

int main(void){
	double x = 0.0, y = 0.0;
	int d = 0,a = 0, an = 90;

	while(true){
		scanf("%d,%d", &d, &a);
		if(d == 0 && a == 0){ break; }
		x += d * cos(dtor(an));
		y += d * sin(dtor(an));
		an -= a;
	}
	printf("%d\n%d\n", (int)x, (int)y);
	return 0;
}

C++: #include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main()
{
	double x=0,y=0;
	double l,a=0,b;
	for(;~scanf("%lf,%lf",&l,&b);)
	{
		x+=l*sin(a);
		y+=l*cos(a);
		a+=b/180*M_PI;
	}
	cout<<(int)x<<"\n"<<(int)y<<endl;
}

C++: #include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
	int w,angle;
	double x=0.0,y=0.0, prev_angle=90.0;
	while( (scanf("%d,%d",&w,&angle)) != EOF){
		if(w==0 && angle==0) break;
		double radian_angle = prev_angle * M_PI / 180.0;
		x += w*cos(radian_angle);
		y += w*sin(radian_angle);
		
		prev_angle -= (double)angle;
	}
	printf("%d\n%d\n",(int)x,(int)y);
	return 0;
}

C++: /*
C++ ???????????????????????????????????¬??????
??????AOJ-ITP1??????????????????
*/
#define _USE_MATH_DEFINES

#include <iostream> // ?¨??????\??????
#include <fstream>  // ??????????????\??????
#include <string>   // ???????????¢???
#include <vector>   // ???????????????
#include <cmath>    // ??°??????
#include <iomanip>  // stream???????????¢???
#include <algorithm>// max??¢??°??????

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;        // ????´???°????????????????????????
using std::fixed;         // ???????????????????¨???????????????????????????????
using std::setprecision;  // ?????°????°???°?????\???????????°????????????????????¨????????\???

int main() {
	double d = 0.0;	// ????????????????????¢
	double a = 0.0;	// ?????????????????????
	double x = 0.0;
	double y = 0.0;
	int ak = 90;	// ???????????????90????????????
	while (true)
	{
		scanf("%lf,%lf", &d, &a);	// double?????????????????????%f??§????????????%lf?????????
		if (d == 0 && a == 0) { break; }
		x += cos(ak*M_PI / 180) * d;
		y += sin(ak*M_PI / 180) * d;
		ak -= a;
		ak %= 360;
	}
	// ??????
	cout << (int)x << "\n" << (int)y << endl;
	return 0;
}