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

#define FOR(i,b,n) for(int i=b;i<n;i++)
#define RFOR(i,b,n) for(int i=n-1;i>=b;i--)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define NCLR(mat) memset(mat, -1, sizeof(mat))

using namespace std;

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

int main()
{
	complex<double> z = complex<double>(0, 0);
	double r, tht = 0, dtht;
	char c;
	
	while(cin >> r >> c >> dtht, (r||dtht))
	{
		z += polar(r, tht*acos(-1.0)/180.0);
		tht += dtht;
	}
	
	cout << (int)z.imag() << endl;
	cout << (int)z.real() << endl;
	
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string.h>
#include <queue>
#include <stack>
#include <utility>
#include <queue>
#include <cmath>
#define mp make_pair
#define pii pair<int,int> 
#define ff first
#define ss second

using namespace std;

double deg,r,x=0,y=0,curdeg=0;

int main()
{
	while(true)
	{
		scanf("%lf,%lf",&r,&deg);
		if(r==0&&deg==0)
		break;
		x+=r*cos(M_PI/180*(90-curdeg));
		y+=r*sin(M_PI/180*(90-curdeg));
		curdeg+=deg;
	}
	printf("%d\n%d\n",(int)x,(int)y);
	return 0;
}

C++: #include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;

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

	double d, a;
	char c;
	while (cin >> d >> c >> a) {
		//cout << "d:" << d << ' ' << "a:" << a << endl;

		double dx, dy;
		dx = cos(angle * PI / 180) * d;
		dy = sin(angle * PI / 180) * d;

		x += dx;
		y += dy;

		angle -= a;
	}

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

C++: #include <algorithm>
#include <cctype>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <queue>
#include <vector>

using namespace std;

const double PI = atan(1)*4;

int main() {
  int r, d;
  double x = 0, y = 0, t = PI / 2.0;
  for (;;) {
    scanf("%d,%d", &r, &d);
    if (!r && !d) {
      printf("%d\n%d\n", int(x), int(y));
      return 0;
    }
    x += double(r) * cos(t);
    y += double(r) * sin(t);
    t -= double(d) * PI / 180.0;
  }
}

C++: /*AOJ 0016*/

#include<iostream>

#define M_PI 3.14159265

using namespace std;

double changeDegToRad(double deg){

	return deg*M_PI/180.0;

}

int main(){

	double x = 0,y = 0;
	double deg = 0,walk = 0;
	double rad = M_PI/2.0;
	while(1){
		scanf("%lf,%lf",&walk,&deg);


		if(deg==0&&walk==0){
			break;
		}

		x += walk * cos(rad);
		y += walk * sin(rad);

		rad -= changeDegToRad(deg);

	}

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

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

int main()
{
    double x = 0;
    double y = 0;
    double a = M_PI_2;
    while(true){
        int d, t;
        char c;
        std::cin >> d >> c >> t;
        if(d == 0 && t == 0) break;
        x += d * std::cos(a);
        y += d * std::sin(a);
        a += (-t * M_PI / 180);
    }
    std::cout << int(x) << std::endl;
    std::cout << int(y) << std::endl;
    return 0;
}

C++: #include<stdio.h>
#include<math.h>
double na;
double nx,ny;

int main(){
	int d;
	int a;
	na=90;
	nx=0;
	ny=0;
	while(1){
		scanf("%d,%d",&d,&a);
		if(d==0&&a==0)break;
		nx+=(double)d*cos(M_PI*na/180);
		ny+=(double)d*sin(M_PI*na/180);
		na-=a;
	}
	printf("%d\n%d\n",(int)nx,(int)ny);
}

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

int main(void)
{
	/*

	const double pi = std::acos(-1.0);

	double r, t;

	for(;;)
	{
		std::cin >> r >> t;

		if(r==0 && t==0)
		{
			break;
		}

		double tRad = t/360.0*2.0*pi;

		std::cout << "(x,y)=" << '(' << r*cos(tRad) << ',' << r*sin(tRad) << ")\n";
	}
	*/
	const double pi = std::acos(-1.0);

	double rIn, tIn;//tInの単位は°

	char c;

	double t = 0;//tの単位はrad

	double x=0, y=0;

	for(;;)
	{
		std::cin >> rIn >> c >> tIn;

		if(rIn==0 && tIn==0)
		{
			break;
		}

		x += rIn*(std::sin(t));

		y += rIn*(std::cos(t));

		t += tIn/360.0*2.0*pi;//°→radの変換した後tに足す

	}

	int xI =x, yI=y;

	std::cout << xI << '\n' << yI << '\n';
	
}

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

using namespace std;

#define PI acos(-1)

double toRad(double ang){
    return (ang*PI/180);
}

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

C++: #define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>


int main()
{
double N,P=0;
double x,y;
double p=0,P1;
x=0;y=0;
while(1)
{
scanf("%lf,%lf",&N,&P1);
if((int)N==0&&(int)P1==0)break;

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

return 0;
}

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

int main(){
double x,y,angle,t,r;
x=0;
y=0;
angle=M_PI/2;
while(1){
scanf("%lf,%lf",&r,&t);
if(r==0&&t==0)break;
x+=r*cos(angle);
y+=r*sin(angle);
angle+=t*M_PI/180;
}
printf("%.0f\n%.0f\n",-x,y);
return 0;
}

C++: #include<stdio.h>
#include<math.h>
int main(){
	double x=0,y=0,angle=90,a,b;
	int ix,iy;
	for(;;){
		scanf("%lf,%lf",&a,&b);
		if(a==0 && b==0){break;}
		x+=(cos(angle*3.1415926/180))*a;
		y+=(sin(angle*3.1415926/180))*a;
		angle-=b;
	}
	ix=x;
	iy=y;
	printf("%d\n%d\n",ix,iy);
	return 0;
}

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,y=0,theta=90;
	int a,b;

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

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

	}

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

	return 0;
}

C++: #include <stdio.h>
#include <complex>
using namespace std;
typedef complex<double> P;
const double pi = atan2(0.0, -1.0);

P unit(double t) { return P(cos(t), sin(t)); }

int main() {
    P cp(0, 0);
    int cd = 90;
    for (;;) {
        int L, d;
        scanf("%d,%d", &L, &d);
        if (L == 0 && d == 0) break;
        cp += (double)L*unit(pi*cd/180);
        cd -= d;
    }
    printf("%d\n%d\n", (int)cp.real(), (int)cp.imag());
    return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <complex>

using namespace std;

const double PI=3.14159265;

int main()
{
	int r,t,T;
	complex<double> ans(0.0,0.0);

	T=90;

	while(scanf("%d,%d",&r,&t)>0){
		ans+=polar((double)r,(double)T*PI/180.0);
		T-=t;
	}
	
	cout<<(int)ans.real()<<endl<<(int)ans.imag()<<endl;

	return 0;

}