Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		m, _ := strconv.Atoi(scanner.Text())
		if m == 0 {
			break
		}
		args1 := make([]float64, m)
		x := 0.0
		for i := 0; i < m-1; i++ {
			scanner.Scan()
			tmp, _ := strconv.ParseFloat(scanner.Text(), 64)
			x += tmp
			args1[i] = tmp
		}
		args1[m-1] = 360-x
		first_object := 0.0
		for _, v := range args1 {
			first_object+= math.Sin(v*math.Pi/180)
		}
		scanner.Scan()
		n, _ := strconv.Atoi(scanner.Text())
		args2 := make([]float64, n)
		y := 0.0
		for i := 0; i < n-1; i++ {
			scanner.Scan()
			tmp, _ := strconv.ParseFloat(scanner.Text(), 64)
			y += tmp
			args2[i] = tmp
		}
		args2[n-1] = 360-y
		second_object := 0.0
		for _, v := range args2 {
			second_object+= math.Sin(v*math.Pi/180)
		}
		if first_object > second_object+ 0.0000001 {
			fmt.Println(1)
		} else if second_object > first_object +0.0000001 {
			fmt.Println(2)
		} else {
			fmt.Println(0)
		}
	}
}

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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int M, N;

int main(){
  while(scanf("%d", &M) && M){
    double f = 0, s = 0;
    int r = 360;
    rep(i, M-1){
      int v;
      scanf("%d", &v);
      f += sin(v / 180.0 * M_PI);
      r -= v;
    }
    f += sin(r / 180.0 * M_PI);

    scanf("%d", &N);
    r = 360;
    rep(i, N-1){
      int v;
      scanf("%d", &v);
      s += sin(v / 180.0 * M_PI);
      r -= v;
    }
    s += sin(r / 180.0 * M_PI);

    if(abs(f-s) < EPS) puts("0");
    else if(f > s) puts("1");
    else puts("2");
  }
  return 0;
}

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

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

int main(){
  int n;
  while(cin>>n, n){
    int sum = 0;
    int ang;
    double s1 = 0.0, s2 = 0.0;
    REP(i,n-1){
      cin>>ang;
      sum += ang;
      s1 += sin(ang/180.0);
    }
    s1 += sin((360-sum)/180.0);

    int m;
    cin >> m;
    sum = 0;
    REP(i,m-1){
      cin>>ang;
      sum += ang;
      s2 += sin(ang/180.0);
    }
    s2 += sin((360-sum)/180.0);

    if(abs(s1-s2) < 1e-15) puts("0");
    else if(s1 > s2) puts("1");
    else puts("2");
  }
  return 0;
}

C++: #include<iostream>
#include<cmath>
using namespace std;
main()
{
	int n,m;
	while(cin>>m,m)
	{
		double T=2*M_PI,v;
		double A=0;
		for(;--m;)
		{
			cin>>v;
			v=v*M_PI/180;
			T-=v;
			A+=sin(v);
		}
		A+=sin(T);
		T=2*M_PI;
		cin>>n;
		for(;--n;)
		{
			cin>>v;
			v=v*M_PI/180;
			T-=v;
			A-=sin(v);
		}
		A-=sin(T);
		cout<<(abs(A)<1e-10?0:A>0?1:2)<<endl;
	}
}

C++: #include <iostream>
#include <complex>
#include <math.h>
#include <vector>
#include <stdio.h>

/*   #include <complex>
complex p(0.0, 0.0);   // 初期化
    // 演算  p + q, p - q, p * 2.0
    // リテラル  complex(1.0, 1.0)
    // リテラル(極座標)  polar(r, a)  長さr, x軸となす角a
	// なす角  angle(p)  pとx軸のなす角
	// なす角  angle(p / q)  pとqのなす角
p.real() = 2.0;
p.imag() = 1.0;   // x, y座標

    // 長さ  abs(p), norm(p)
	// ベクトル回転  p * polar(1.0, M_PI / 2)
*/

using namespace std;

typedef complex<double> Point;    // 座標型

// 座標ソート
bool xycomp(const Point &a, const Point &b){
	if(a.real() != b.real())
		return a.real() < b.real();
	return a.imag() < b.imag();
}


// 偏角と長さでソート
bool argcomp(const Point &a, const Point &b){
	double aa = arg(a) < 0.0 ? 2 * M_PI - arg(a) : arg(a);
	double bb = arg(b) < 0.0 ? 2 * M_PI - arg(b) : arg(b);
	if(aa != bb)
		return aa < bb;
	return abs(a) < abs(b);
}



double dot(Point a, Point b){     // 内積
	return real(conj(a) * b);
}

double cross(Point a, Point b){   // 外積  |a||b|sinθ
	return imag(conj(a) * b);
}

// 三角形の面積  ||v||u|sinθ/ 2| = abs(cross(v, u) / 2)

    // 多角形の面積
double area(vector<Point> poly){    //poly[] 多角形の頂点
	int n = poly.size();
	double a = 0.0;
	
	for(int i = 0; i < n; i++){
		
		a += cross(poly[i], poly[(i + 1)%n]) / 2;
	}
	
	return abs(a);
}


/*   // 多角形の外接円
Point circumcircle(Point poly[]){
	Point c = Point(0.0, 0.0);
	double ratio = 0.5;
	
	for(int k = 0; k = 100; k++){
		for(int i = 0; i < 100; i++){
			Point p = ;// 一番離れている点
			c += (p - c) * ratio;
		}
		ratio *= 0.5;
	}
	return c;
}
*/


int main(){
	while(1){
		int m;
		cin >> m;
		if(m == 0)
			break;
		
		vector<int> v1(m);
		for(int i = 0; i < m-1; i++)
			cin >> v1[i];
		
		int n;
		cin >> n;
		
		vector<int> v2(n);
		for(int i = 0; i < n-1; i++)
			cin >> v2[i];
		
		vector<Point> p1(m);
		
		p1[0] = Point(1.0, 0);
		
		for(int i = 1, j =0; i < m; i++){
			j += v1[i - 1];
			p1[i] = polar(1.0, j * M_PI / 180);
		}
		
		double s1 = area(p1);
		
		
		
		vector<Point> p2(n);
		
		
		
		p2[0] = Point(1.0, 0);
		
		for(int i = 1, j =0; i < n; i++){
			j += v2[i - 1];
			p2[i] = polar(1.0, j * M_PI / 180);
		}
		
		double s2 = area(p2);
		
		if(s1 == s2)
			puts("0");
		else if(s1 > s2)
			puts("1");
		else
			puts("2");
	}
	
	return 0;
}

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

#define PI	3.1415926535
#define EPS	0.00000000001

int main()
{
	int n,a;
	int a1,a2;
	double h1,h2;

	while(cin >> n, n)
	{
		a1=a2=0;
		h1=h2=0;
		while(--n)
		{
			cin >> a;
			a1 += a;
			h1 += sin(a*PI/360.0);
		}
		cin >> n;
		while(--n)
		{
			cin >> a;
			a2 += a;
			h2 += sin(a*PI/360.0);
		}

		h1 += sin((360-a1)*PI/360.0);
		h2 += sin((360-a2)*PI/360.0);

		if(-EPS<h1-h2 && h1-h2<EPS)
		{
			cout << 0 << endl;
		}
		else if(h1>h2)
		{
			cout << 1 << endl;
		}
		else
		{
			cout << 2 << endl;
		}
	}

	return 0;
}

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

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

const double EPS = 1e-5;

int main()
{
	int m;
	while(scanf("%d", &m), m){
		double sm1 = 0.0;
		rep(i, m-1){
			int deg;
			scanf("%d", &deg);
			sm1 += sin(deg*M_PI/180.0);
		}
		
		int n;
		scanf("%d", &n);
		
		double sm2 = 0.0; 
		rep(i, n-1){
			int deg;
			scanf("%d", &deg);
			sm2 += sin(deg*M_PI/180.0);
		}
		
		if(fabs(sm1 - sm2) < EPS)
			puts("0");
		else
			puts(sm1>sm2 ? "1" : "2");
	}
}