#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <tuple>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;
class TellBagsApart { public:
string whichBagIsSmaller(vector <int> records)
{
srand(time(0));
string ans;
for (int i = 0; i < records.size(); i += 8)
ans += char('0' + solve(vector<int>(records.begin() + i, records.begin() + i + 8)));
return ans;
}
int solve(vector<int> r) {
// same = 3/7, diff = 4/7
// same = 19/39, diff = 20/39
int a1 = r[0] + r[1] + r[2] + r[3];
int s1 = r[0] + r[3];
int d1 = a1 - s1;
int a2 = r[4] + r[5] + r[6] + r[7];
int s2 = r[4] + r[7];
int d2 = a2 - s2;
int lhs, rhs;
if (a1 == 0) {
// s2/a2 closer to 19/39 ? 1 : 2
// 125/273 < s2/a2
lhs = 125 * a2;
rhs = s2 * 273;
}
else if (a2 == 0) {
// s1/a1 closer to 3/7 ? 1 : 2
// s1/a1 < 125/273
lhs = s1 * 273;
rhs = 125 * a1;
}
else {
// s1/a1 < s2/a2 ? 1 : 2
lhs = s1 * a2;
rhs = s2 * a1;
}
if (lhs == rhs) {
return (rand() >> 8) & 1 ? 1 : 2;
}
else {
return lhs < rhs ? 1 : 2;
}
}
};
// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
{ ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
{ os << "{ ";
for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
void verify_case(const string& Expected, const string& Received) {
bool ok = (Expected == Received);
if(ok) cerr << "PASSED" << timer() << endl; else { cerr << "FAILED" << timer() << endl;
cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } }
#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
#define END verify_case(_, TellBagsApart().whichBagIsSmaller(records));}
int main(){
CASE(0)
int records_[] = {262, 371, 340, 277, 303, 304, 333, 310,
296, 326, 370, 275, 312, 329, 284, 308,
265, 402, 372, 279, 279, 317, 307, 279,
112, 160, 121, 102, 497, 497, 505, 506};
vector <int> records(records_, records_+sizeof(records_)/sizeof(*records_));
string _ = "1111";
END
CASE(1)
int records_[] = {401, 405, 345, 358, 203, 295, 284, 209,
348, 380, 396, 361, 221, 274, 307, 213,
361, 347, 410, 347, 246, 287, 298, 204,
301, 389, 412, 304, 253, 289, 280, 272,
303, 450, 388, 290, 270, 286, 246, 267,
328, 354, 326, 362, 254, 305, 309, 262,
290, 362, 391, 296, 285, 282, 313, 281,
338, 335, 345, 335, 220, 338, 335, 254,
309, 356, 348, 323, 239, 344, 343, 238,
264, 368, 365, 258, 301, 312, 328, 304,
256, 368, 343, 295, 296, 323, 319, 300,
275, 318, 383, 258, 320, 340, 306, 300,
275, 301, 323, 309, 273, 372, 366, 281,
263, 331, 290, 309, 277, 358, 395, 277,
261, 310, 291, 259, 301, 407, 379, 292,
256, 318, 297, 257, 325, 358, 366, 323,
284, 287, 274, 286, 294, 406, 358, 311,
266, 271, 282, 256, 282, 395, 429, 319,
270, 274, 278, 268, 308, 396, 404, 302,
203, 283, 299, 229, 368, 401, 377, 340};
vector <int> records(records_, records_+sizeof(records_)/sizeof(*records_));
string _ = "22211212211122212221";
END
/*
CASE(2)
int records_[] = ;
vector <int> records(records_, records_+sizeof(records_)/sizeof(*records_));
string _ = ;
END
CASE(3)
int records_[] = ;
vector <int> records(records_, records_+sizeof(records_)/sizeof(*records_));
string _ = ;
END
*/
}
// END CUT HERE