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 <bits/stdc++.h>
using namespace std;
//define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// 許容する誤差ε
#define EPS (1e-10)
// 2つのスカラーが等しいかどうか
#define EQ(a,b) (abs((a)-(b)) < EPS)
// 2つのベクトルが等しいかどうか
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
//template
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
//typedef
typedef complex<double> Point;
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;



double cross(Point a, Point b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}

int a[100], b[100];
signed main(){
  while(1){
    int n, m, s1 = 0, s2 = 0;
    scanf("%lld", &n);
    if(n == 0)break;
    rep(i,n-1){scanf("%lld", &a[i]);s1 += a[i];}
    scanf("%lld", &m);
    rep(i,m-1){scanf("%lld", &b[i]);s2 += b[i];}
    a[n-1] = 360-s1;b[m-1] = 360-s2;
    
    double S1 = 0, S2 = 0;
    rep(i,n){
      double r = a[i]/180.0*M_PI;
      Point p1 = Point(1, 0);
      Point p2 = Point(cos(r), sin(r));
      S1 += cross(p1, p2);
    }
    rep(i,m){
      double r = b[i]/180.0*M_PI;
      Point p1 = Point(1, 0);
      Point p2 = Point(cos(r), sin(r));
      S2 += cross(p1, p2);
    }
    if(EQ(S1, S2))printf("0\n");
    else if(S1-S2 > -EPS)printf("1\n");
    else printf("2\n");
  }
	return 0;
}

C++: #include <iostream>

using namespace std;

#define PI 3.1415926535

int main() {
	int n, m;
	while(cin >> n) {
		if (n == 0) {
			break;
		}
		int counter = 360;
		int a;
		double men1 = 0.0;
		for (int i = 0; i < n-1; i++) {
			cin >> a;
			men1 += 0.5*1.0*1.0*sin(((double)a/360.0)*PI*2.0);
			counter -= a;
		}
		men1 += 0.5*1.0*1.0*sin(((double)a/360.0)*PI*2.0);
		cin >> m;
		counter = 360;
		double men2 = 0.0;
		for (int i = 0; i < m-1; i++) {
			cin >> a;
			men2 += 0.5*1.0*1.0*sin(((double)a/360.0)*PI*2.0);
			counter -= a;
		}
		men2 += 0.5*1.0*1.0*sin(((double)a/360.0)*PI*2.0);
		if (men1 == men2) {
			cout << 0 << endl;
		} else if (men1 > men2){
			cout << 1 << endl;
		} else {
			cout << 2 << endl;
		}
	}
	return 0;
}

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

using namespace std;
static double EPS = 1.0e-10;

bool is_zero(const double x){ return abs(x)<EPS; }
double get_area(const double& t){ return sin(t*M_PI/180.0)/2; }

double solve(const int& n){
  double ans=0;
  double t, t_=360;
  for(int i=0; i<n-1; ++i){
    cin >> t;
    t_-=t;
    ans+=get_area(t);
  }
  ans+=get_area(t_);
  return ans;
}

int main(){
  int n, m;
  while(cin >> n && n){
    double a=solve(n);
    cin >> m;
    double b=solve(m);
    if(is_zero(a-b)) printf("0\n");
    else if(a>b) printf("1\n");
    else printf("2\n");
  }
  return 0;
}

C++: #include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
double PI = asin(0.5)*6.0;

void mainmain(){
	int n,m;
	// printf("%.6lf\n",PI);
	while(cin>>n,n){
		double t1=0,t2=0;
		double tt1=360,tt2=360;
		rep(i,n-1){
			double t;
			cin>>t;
			tt1-=t;
			t1+=sin(t/180*PI);
		}
		t1+=sin(tt1/180*PI);
		cin>>m;
		rep(i,m-1){
			double t;
			cin>>t;
			tt2-=t;
			t2+=sin(t/180*PI);
		}
		t2+=sin(tt2/180*PI);
		if(t1-t2>EPS) cout<<1<<endl;
		else if(t1-t2<-EPS) cout<<2<<endl;
		else cout<<0<<endl; 
	}
}



}
main() try{
    mainmain();
}
catch(...){
}