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 <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <array>
#include <numeric>
#include <functional>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<complex>

using namespace std;

#define REP(i,m,n) for(int i=m;i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define ALL(x) (x).begin(),(x).end()

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

// const ll inf = INT_MAX;
const double eps = 1e-10;
const double pi = acos(-1.0);
const int di[][2] = {{1,0},{0,1},{-1,0},{0,-1},{1,1},{1,-1},{-1,1},{-1,-1}};

int main(){

	int r;
	double x=0, y=0;
	double ini = pi/2, alpha, theta;
	cout << endl;
	while(scanf("%d,%lf\n", &r, &theta)){
		if(r == 0 && std::abs(theta - 0.0) < eps){
			// printf("finished\n");
			break;
		}
		else{
			x += r*cos(ini);
			y += r*sin(ini);
			alpha = pi*theta/180;
			ini -= alpha;
		}
	}
	printf("%d\n%d\n", (int)x, (int)y);
	return 0;
}

C++: #include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>
#include<cmath>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)


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

const double EPS = 0.000000001;

int main(){
	
	int a,b;
	double angle = M_PI/2;
	P pos = P(0,0);
	
	while(scanf("%d,%d",&a,&b)){
		if(a==0 && b==0)break;
		pos += P(cos(angle),sin(angle))*(double)a;
		angle += b/180.0*M_PI;
	}
	
	printf("%d %d\n",int(-pos.X-0.5+EPS),int(pos.Y-0.5+EPS));
}

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

#define PI 3.1415926535897932384

using namespace std;

int main() {
	double x = 0, y = 0;
	int t = 90;
	
	while (1) {
		int d, it;
		scanf("%d,%d", &d, &it);
		if (d==0 && it==0) break;
		
		x += d * cos((double)t * PI/180.);
		y += d * sin((double)t * PI/180.);
		
		t -= it;
	}
	
	cout << (int)x << endl << (int)y << endl;
	
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#define M_PI 3.14159265358979323846

using namespace std;

typedef struct location {
        double x, y;
        int deg;

        location():
                x(0.0), y(0.0), deg(0)
                {
                }
} location;

int main()
{
        location loc;
        int d, a;

        while (true) {
                scanf("%d,%d", &d, &a);
                if (d == 0 && a == 0)
                        break;
                loc.x += d * sin(loc.deg * M_PI / 180);
                loc.y += d * cos(loc.deg * M_PI / 180);
                loc.deg += a;
        }
        cout << static_cast<int>(loc.x) << endl;
        cout << static_cast<int>(loc.y) << endl;

        return 0;
}

C++: #define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int main() {
	double x = 0, y = 0;
	double dist, ang = 0, d;
	while (scanf("%lf,%lf", &dist, &d), dist || d) {
		x += sin(ang*M_PI / 180)*dist;
		y += cos(ang*M_PI / 180)*dist;
		ang += d;
	}
	cout << (int)x << endl << (int)y << endl;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <stdio.h>

#define PI 3.14159265358979323846264

using namespace std;

int main()
{
	double x=0.0,y=0.0;
	int a,b,theta=90;

	scanf("%d,%d",&a,&b);
	while(a!=0 && b!=0){
		x+=a*cos(theta*PI/180.0);
		y+=a*sin(theta*PI/180.0);

		theta-=b;
		scanf("%d,%d",&a,&b);

	}

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

	return 0;
}

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

#define PI 3.141592

int main() {
  double l, ang;
  double nowang = PI/2;
  double x = 0, y = 0;
  while(true) {
    scanf("%lf,%lf", &l,&ang);
    if (l+ang==0) break;
    x += cos(nowang) * l;
    y += sin(nowang) * l;
    nowang -= ang * PI / 180;
  }
  printf("%d\n%d\n", (int)x,(int)y);
}

C++: #include<iostream>
#include<cmath>
#include<stdio.h>
#define PI 3.141592653589793
using namespace std;

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

	int angle = 90;

	int l, a;

	while(scanf("%d,%d",&l,&a) + 1){
		if(l == 0 && a == 0)break;

		x -= l * cos(angle * PI / 180);
		y += l * sin(angle * PI / 180);

		angle += a;
	}

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

	return 0;
}

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

int main()
{
	double PI = atan(1.0)*4;
	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;
}

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

int main(void) {
  double x = 0, y = 0;
  int d = 90;
  while( 1 ) {
    int a, b;
    scanf("%d,%d", &a, &b);
    if(!a && !b) break;
    x += cos((double)d / 180.0 * pi) * a;
    y += sin((double)d / 180.0 * pi) * a;
    //printf("%d %d %d\n", d, (int)x, (int)y);
    d -= b;
    d %= 360;
  }
  printf("%d\n%d\n", (int)x, (int)y);
  return 0;
}

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

C++: //14
#include<iostream>
#include<complex>
#include<cmath>

using namespace std;

int main(){
  complex<double> p;
  double ang=0;
  for(double a,b;(cin>>a).ignore()>>b,a!=0||b!=0;){
    p+=polar(a,ang/180*acos(-1));
    ang+=b;
  }
  cout<<(int)p.imag()<<endl<<(int)p.real()<<endl;
  return 0;
}

C++: //#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

signed main(void)
{
	double x = 0, y = 0;
	int ang = 90;
	while(true) {
		int r, t;
		cin >> r;
		x += r*cos(ang*PI/180);
		y += r*sin(ang*PI/180);
		cin.ignore(); cin >> t;
		if(!r && !t) break;
		ang -= t;
		ang = (ang + 360) % 360;
	}
	cout << (int)x << endl << (int)y << endl;

	return 0;
}

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

#define PI 3.14159265358979
#define rad(deg) ((deg) / 180 * PI) 

using namespace std;

int main() {
	int d, a;
	float x = 0., y = 0., deg = 0.;

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

		x += d * sin(rad(deg));
		y += d * cos(rad(deg));

		deg += a;
	}

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