#pragma comment(linker, "/stack:20000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
//# include <opencv2/core/core.hpp>
//# include <opencv2/highgui/highgui.hpp>
//# include <opencv2/imgproc/imgproc.hpp>
using namespace std;
// Let's define unordered map
# ifdef __GNUC__
# if __cplusplus > 199711L
# include <unordered_set>
# include <unordered_map>
# else
# include <tr1/unordered_map>
# include <tr1/unordered_set>
using namespace tr1;
# endif
# else
# include <unordered_map>
# include <unordered_set>
# endif
#define VA_NUM_ARGS(...) VA_NUM_ARGS_IMPL_((0,__VA_ARGS__, 6,5,4,3,2,1))
#define VA_NUM_ARGS_IMPL_(tuple) VA_NUM_ARGS_IMPL tuple
#define VA_NUM_ARGS_IMPL(_0,_1,_2,_3,_4,_5,_6,N,...) N
#define macro_dispatcher(macro, ...) macro_dispatcher_(macro, VA_NUM_ARGS(__VA_ARGS__))
#define macro_dispatcher_(macro, nargs) macro_dispatcher__(macro, nargs)
#define macro_dispatcher__(macro, nargs) macro_dispatcher___(macro, nargs)
#define macro_dispatcher___(macro, nargs) macro ## nargs
#define DBN1(a) cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define DBN(...) macro_dispatcher(DBN, __VA_ARGS__)(__VA_ARGS__)
#define DA(a,n) cerr<<#a<<"=["; printarray(a,n); cerr<<"]\n"
#define DAR(a,n,s) cerr<<#a<<"["<<s<<"-"<<n-1<<"]=["; printarray(a,n,s); cerr<<"]\n"
#ifdef _MSC_VER
#define PREFETCH(ptr, rw, level) ((void)0)
#else
#define PREFETCH(ptr, rw, level) __builtin_prefetch(ptr, rw, level)
#endif
#ifdef LOCAL
#define CURTIME() cerr << clock() * 1.0 / CLOCKS_PER_SEC << endl
#else
#define CURTIME()
#endif
#define mp make_pair
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair< int , int > pii;
typedef pair< long long , long long > pll;
typedef vector< int > vi;
typedef vector< long long > vll;
typedef int itn;
template < class T1, class T2, class T3>
struct triple{ T1 a; T2 b; T3 c; triple( ) : a( T1( ) ) , b( T2( ) ) , c( T3( ) ) { } ; triple( T1 _a, T2 _b, T3 _c) : a( _a) , b( _b) , c( _c) { } } ;
template < class T1, class T2, class T3>
bool operator< ( const triple< T1,T2,T3> & t1,const triple< T1,T2,T3> & t2) { if ( t1.a ! = t2.a ) return t1.a < t2.a ; else if ( t1.b ! = t2.b ) return t1.b < t2.b ; else return t1.c < t2.c ; }
template < class T1, class T2, class T3>
bool operator> ( const triple< T1,T2,T3> & t1,const triple< T1,T2,T3> & t2) { if ( t1.a ! = t2.a ) return t1.a > t2.a ; else if ( t1.b ! = t2.b ) return t1.b > t2.b ; else return t1.c > t2.c ; }
#define tri triple<int,int,int>
#define trll triple<ll,ll,ll>
#define FI(n) for(int i=0;i<(n);++i)
#define FJ(n) for(int j=0;j<(n);++j)
#define FK(n) for(int k=0;k<(n);++k)
#define FL(n) for(int l=0;l<(n);++l)
#define FQ(n) for(int q=0;q<(n);++q)
#define FOR(i,a,b) for(int i = (a), __e = (int) (b); i < __e; ++i)
#define all(a) std::begin(a), std::end(a)
#define reunique(v) v.resize(std::unique(v.begin(), v.end()) - v.begin())
#define sqr(x) ((x) * (x))
#define sqrt(x) sqrt(1.0 * (x))
#define pow(x, n) pow(1.0 * (x), n)
#define COMPARE(obj) [&](const std::decay_t<decltype(obj)>& a, const std::decay_t<decltype(obj)>& b)
#define COMPARE_BY(obj, field) [&](const std::decay_t<decltype(obj)>& a, const std::decay_t<decltype(obj)>& b) { return a.field < b.field; }
#define checkbit(n, b) (((n) >> (b)) & 1)
#define setbit(n, b) ((n) | (static_cast<std::decay_t<decltype(n)>>(1) << (b)))
#define removebit(n, b) ((n) & ~(static_cast<std::decay_t<decltype(n)>>(1) << (b)))
#define flipbit(n, b) ((n) ^ (static_cast<std::decay_t<decltype(n)>>(1) << (b)))
inline int countBits( uint v) { v= v- ( ( v>> 1 ) & 0x55555555 ) ; v= ( v& 0x33333333 ) + ( ( v>> 2 ) & 0x33333333 ) ; return ( ( v+ ( v>> 4 ) & 0xF0F0F0F ) * 0x1010101 ) >> 24 ; }
inline int countBits( ull v) { uint t= v>> 32 ; uint p= ( v & ( ( 1ULL << 32 ) - 1 ) ) ; return countBits( t) + countBits( p) ; }
inline int countBits( ll v) { return countBits( ( ull) v) ; }
inline int countBits( int v) { return countBits( ( uint) v) ; }
unsigned int reverseBits( uint x) { x = ( ( ( x & 0xaaaaaaaa ) >> 1 ) | ( ( x & 0x55555555 ) << 1 ) ) ; x = ( ( ( x & 0xcccccccc ) >> 2 ) | ( ( x & 0x33333333 ) << 2 ) ) ; x = ( ( ( x & 0xf0f0f0f0 ) >> 4 ) | ( ( x & 0x0f0f0f0f ) << 4 ) ) ; x = ( ( ( x & 0xff00ff00 ) >> 8 ) | ( ( x & 0x00ff00ff ) << 8 ) ) ; return ( ( x >> 16 ) | ( x << 16 ) ) ; }
template < class T> inline int sign( T x) { return x > 0 ? 1 : x < 0 ? - 1 : 0 ; }
inline bool isPowerOfTwo( int x) { return ( x ! = 0 && ( x& ( x - 1 ) ) == 0 ) ; }
constexpr ll power( ll x, int p) { return p == 0 ? 1 : ( x * power( x, p - 1 ) ) ; }
template < class T1, class T2, class T3> T1 inline clamp( T1 x, const T2& a, const T3& b) { if ( x < a) return a; else if ( x > b) return b; else return x; }
unsigned long long rdtsc( ) { unsigned long long ret = 0 ;
#ifdef __clang__
return __builtin_readcyclecounter( ) ;
#endif
#ifndef _MSC_VER
asm volatile ( "rdtsc" : "=A" ( ret) : : ) ;
#endif
return ret; }
// Fast IO ********************************************************************************************************
const int __BS = 4096 ;
static char __bur[ __BS + 16 ] , * __er = __bur + __BS, * __ir = __er;
template < class T = int > T readInt( ) {
auto c = [ & ] ( ) { if ( __ir == __er) std:: fill ( __bur, __bur + __BS, 0 ) , cin .read ( __bur, __BS) , __ir = __bur; } ;
c( ) ; while ( * __ir && ( * __ir < '0' || * __ir > '9' ) && * __ir ! = '-' ) ++ __ir; c( ) ;
bool m = false ; if ( * __ir == '-' ) ++ __ir, c( ) , m = true ;
T r = 0 ; while ( * __ir >= '0' && * __ir <= '9' ) r = r * 10 + * __ir - '0' , ++ __ir, c( ) ;
++ __ir; return m ? - r : r;
}
static char __buw[ __BS + 20 ] , * __iw = __buw, * __ew = __buw + __BS;
template < class T>
void writeInt( T x, char endc = '\n ' ) {
if ( x < 0 ) * __iw++ = '-' , x = - x; if ( x == 0 ) * __iw++ = '0' ;
char * s = __iw;
while ( x) { T t = x / 10 ; char c = x - 10 * t + '0' ; * __iw++ = c; x = t; }
char * f = __iw - 1 ; while ( s < f) swap( * s, * f) , ++ s, -- f;
if ( __iw > __ew) cout .write ( __buw, __iw - __buw) , __iw = __buw;
* __iw++ = endc;
}
template < class T>
void writeStr( const T& str) {
int i = 0 ; while ( str[ i] ) { * __iw++ = str[ i++ ] ; if ( __iw > __ew) cout .write ( __buw, __iw - __buw) , __iw = __buw; }
}
struct __FL__ { ~__FL__( ) { if ( __iw ! = __buw) cout .write ( __buw, __iw - __buw) ; } } ;
static __FL__ __flushVar__;
//STL output *****************************************************************************************************
#define TT1 template<class T>
#define TT1T2 template<class T1, class T2>
#define TT1T2T3 template<class T1, class T2, class T3>
TT1T2 ostream& operator << ( ostream& os, const pair< T1, T2> & p) ;
TT1 ostream& operator << ( ostream& os, const vector< T> & v) ;
TT1T2 ostream& operator << ( ostream& os, const set< T1, T2> & v) ;
TT1T2 ostream& operator << ( ostream& os, const multiset< T1, T2> & v) ;
TT1T2 ostream& operator << ( ostream& os, priority_queue< T1, T2> v) ;
TT1T2T3 ostream& operator << ( ostream& os, const map< T1, T2, T3> & v) ;
TT1T2T3 ostream& operator << ( ostream& os, const multimap< T1, T2, T3> & v) ;
TT1T2T3 ostream& operator << ( ostream& os, const triple< T1, T2, T3> & t) ;
template < class T, size_t N> ostream& operator << ( ostream& os, const array< T, N> & v) ;
TT1T2 ostream& operator << ( ostream& os, const pair< T1, T2> & p) { return os << "(" << p.first << ", " << p.second << ")" ; }
TT1 ostream& operator << ( ostream& os, const vector< T> & v) { bool f= 1 ; os<< "[" ; for ( auto & i : v) { if ( ! f) os << ", " ; os<< i; f= 0 ; } return os << "]" ; }
template < class T, size_t N> ostream& operator << ( ostream& os, const array< T, N> & v) { bool f= 1 ; os<< "[" ; for ( auto & i : v) { if ( ! f) os << ", " ; os<< i; f= 0 ; } return os << "]" ; }
TT1T2 ostream& operator << ( ostream& os, const set< T1, T2> & v) { bool f= 1 ; os<< "[" ; for ( auto & i : v) { if ( ! f) os << ", " ; os<< i; f= 0 ; } return os << "]" ; }
TT1T2 ostream& operator << ( ostream& os, const multiset< T1,T2> & v) { bool f= 1 ; os<< "[" ; for ( auto & i : v) { if ( ! f) os << ", " ; os<< i; f= 0 ; } return os << "]" ; }
TT1T2T3 ostream& operator << ( ostream& os, const map< T1,T2,T3> & v) { bool f = 1 ; os << "[" ; for ( auto & ii : v) { if ( ! f) os << ", " ; os << "(" << ii.first << " -> " << ii.second << ") " ; f = 0 ; } return os << "]" ; }
TT1T2 ostream& operator << ( ostream& os, const multimap< T1, T2> & v) { bool f = 1 ; os << "[" ; for ( auto & ii : v) { if ( ! f) os << ", " ; os << "(" << ii.first << " -> " << ii.second << ") " ; f = 0 ; } return os << "]" ; }
TT1T2 ostream& operator << ( ostream& os, priority_queue< T1, T2> v) { bool f = 1 ; os << "[" ; while ( ! v.empty ( ) ) { auto x = v.top ( ) ; v.pop ( ) ; if ( ! f) os << ", " ; f = 0 ; os << x; } return os << "]" ; }
TT1T2T3 ostream& operator << ( ostream& os, const triple< T1, T2, T3> & t) { return os << "(" << t.a << ", " << t.b << ", " << t.c << ")" ; }
TT1T2 void printarray( const T1& a, T2 sz, T2 beg = 0 ) { for ( T2 i = beg; i< sz; i++ ) cout << a[ i] << " " ; cout << endl; }
//STL input *****************************************************************************************************
TT1T2T3 inline istream& operator >> ( istream& os, triple< T1, T2, T3> & t) ;
TT1T2 inline istream& operator >> ( istream& os, pair< T1, T2> & p) { return os >> p.first >> p.second ; }
TT1 inline istream& operator >> ( istream& os, vector< T> & v) {
if ( v.size ( ) ) for ( T& t : v) os >> t; else {
string s; T obj; while ( s.empty ( ) ) { getline( os, s) ; if ( ! os) return os; }
stringstream ss( s) ; while ( ss >> obj) v.push_back ( obj) ;
}
return os;
}
TT1T2T3 inline istream& operator >> ( istream& os, triple< T1, T2, T3> & t) { return os >> t.a >> t.b >> t.c ; }
//Pair magic *****************************************************************************************************
#define PT1T2 pair<T1, T2>
TT1T2 inline PT1T2 operator+ ( const PT1T2 & p1 , const PT1T2 & p2) { return PT1T2( p1.first + p2.first , p1.second + p2.second ) ; }
TT1T2 inline PT1T2& operator+ = ( PT1T2 & p1 , const PT1T2 & p2) { p1.first + = p2.first , p1.second + = p2.second ; return p1; }
TT1T2 inline PT1T2 operator- ( const PT1T2 & p1 , const PT1T2 & p2) { return PT1T2( p1.first - p2.first , p1.second - p2.second ) ; }
TT1T2 inline PT1T2& operator- = ( PT1T2 & p1 , const PT1T2 & p2) { p1.first - = p2.first , p1.second - = p2.second ; return p1; }
#undef TT1
#undef TT1T2
#undef TT1T2T3
#define FREIN(FILE) freopen(FILE, "rt", stdin)
#define FREOUT(FILE) freopen(FILE, "wt", stdout)
#ifdef LOCAL
#define BEGIN_PROFILE(idx, name) int profileIdx = idx; profileName[profileIdx] = name; totalTime[profileIdx] -= rdtsc() / 1e3;
#define END_PROFILE totalTime[profileIdx] += rdtsc() / 1e3; totalCount[profileIdx]++;
#else
#define BEGIN_PROFILE(idx, name)
#define END_PROFILE
#endif
template < class T> inline void normmod( T & x, T m) { x % = m; if ( x < 0 ) x + = m; }
template < class T1, class T2> inline T2 summodfast( T1 x, T1 y, T2 m) { T2 res = x + y; if ( res >= m) res - = m; return res; }
template < class T1, class T2, class T3> inline void addmodfast( T1 & x, T2 y, T3 m) { x + = y; if ( x >= m) x - = m; }
template < class T1, class T2, class T3> inline void submodfast( T1 & x, T2 y, T3 m) { x - = y; if ( x < 0 ) x + = m; }
#if INTPTR_MAX == INT32_MAX or !defined(__SIZEOF_INT128__)
inline ll mulmod( ll x, ll n, ll m) { ll r = 0 ; normmod( x, m) ; normmod( n, m) ; while ( n) { if ( n & 1 ) r + = x; x + = x; if ( r >= m) r - = m; if ( x >= m) x - = m; n / = 2 ; } return r; }
#else
using int128 = __int128;
inline ll mulmod( ll x, ll n, ll m) { return __int128( x) * n % m; }
#endif
inline ll powmod( ll x, ll n, ll m) { ll r = 1 ; normmod( x, m) ; while ( n) { if ( n & 1 ) r = ( r* x) % m; x = ( x* x) % m; n / = 2 ; } return r; }
inline ll powmulmod( ll x, ll n, ll m) { ll res = 1 ; normmod( x, m) ; while ( n) { if ( n & 1 ) res = mulmod( res, x, m) ; x = mulmod( x, x, m) ; n / = 2 ; } return res; }
template < class T> inline T gcd( T a, T b) { while ( b) { a % = b; T t = a; a = b; b = t; } return a; }
inline ll lcm( ll a, ll b) { return a / gcd( a, b) * b; }
template < class T> inline T gcd( T a, T b, T c) { return gcd( gcd( a, b) , c) ; }
ll gcdex( ll a, ll b, ll& x, ll& y) {
if ( ! a) { x = 0 ; y = 1 ; return b; }
ll y1; ll d = gcdex( b % a, a, y, y1) ; x = y1 - ( b / a) * y;
return d;
}
template < class T> bool isPrime( T x) { if ( x <= 4 || x % 2 == 0 || x % 3 == 0 ) return x == 2 || x == 3 ;
for ( T i = 5 ; i * i <= x; i + = 6 ) if ( x % i == 0 || x % ( i + 2 ) == 0 ) return 0 ; return 1 ; }
bool millerRabin( long long n) {
if ( n <= 1000 ) return isPrime( n) ;
long long s = n - 1 ; int t = 0 ; while ( s % 2 == 0 ) s / = 2 , ++ t;
for ( int a : { 2 , 325 , 9375 , 28178 , 450775 , 9780504 , 1795265022 } ) { if ( ! ( a % = n) ) return true ;
long long f = powmulmod( a, s, n) ; if ( f == 1 || f == n - 1 ) continue ;
for ( int i = 1 ; i < t; ++ i) if ( ( f = mulmod( f, f, n) ) == n - 1 ) goto nextp;
return false ; nextp:;
} return true ;
}
// Useful constants
//int some_primes[7] = {24443, 100271, 1000003, 1000333, 5000321, 98765431, 1000000123};
#define T9 1000000000
#define T18 1000000000000000000LL
#define INF 1011111111
#define LLINF 1000111000111000111LL
#define mod 1000000007
#define EPS (double)1e-10
#define PI 3.14159265358979323846264
#define link asaxlajrewqwe
#define rank wahayawehasdakw
//*************************************************************************************
int32_t solve( ) ;
int32_t main( int argc, char ** argv) {
ios_base:: sync_with_stdio ( 0 ) ; cin .tie ( 0 ) ;
#ifdef LOCAL
// FREIN("input.txt");
// FREOUT("out.txt");
#endif
return solve( ) ;
}
const int N = 4050 ;
int ps1[ N] [ N] ;
using T = decltype( ps1) ;
T rd, ld, lu, ru;
int solve( ) {
int n;
cin >> n;
FI( n) {
char c;
cin >> c;
int x, y, z;
cin >> x >> y >> z;
x + = 2002 ;
y + = 2002 ;
if ( c == 'A' ) {
x + = z / 2 ;
y + = z / 2 ;
ps1[ x] [ y] ++ ;
ps1[ x] [ y - z] -- ;
ps1[ x - z] [ y] -- ;
ps1[ x - z] [ y - z] ++ ;
} else {
rd[ x + z / 2 ] [ y] ++ ;
rd[ x] [ y + z / 2 ] -- ;
rd[ x] [ y - z / 2 ] -- ;
rd[ x - z / 2 ] [ y] ++ ;
rd[ x + z / 2 - 1 ] [ y] ++ ;
rd[ x - 1 ] [ y + z / 2 ] -- ;
rd[ x] [ y - z / 2 + 1 ] -- ;
rd[ x - z / 2 ] [ y + 1 ] ++ ;
ld[ x + z / 2 ] [ y + 1 ] ++ ;
ld[ x] [ y - z / 2 + 1 ] -- ;
ld[ x] [ y + z / 2 + 1 ] -- ;
ld[ x - z / 2 ] [ y + 1 ] ++ ;
ld[ x + z / 2 - 1 ] [ y + 1 ] ++ ;
ld[ x] [ y + z / 2 ] -- ;
ld[ x - 1 ] [ y - z / 2 + 1 ] -- ;
ld[ x - z / 2 ] [ y] ++ ;
lu[ x + z / 2 - 1 ] [ y] ++ ;
lu[ x] [ y - z / 2 + 1 ] -- ;
lu[ x - 1 ] [ y + z / 2 ] -- ;
lu[ x - z / 2 ] [ y + 1 ] ++ ;
lu[ x + z / 2 - 1 ] [ y + 1 ] ++ ;
lu[ x - 1 ] [ y + z / 2 + 1 ] -- ;
lu[ x - 1 ] [ y - z / 2 + 1 ] -- ;
lu[ x - z / 2 - 1 ] [ y + 1 ] ++ ;
ru[ x + z / 2 - 1 ] [ y] ++ ;
ru[ x - 1 ] [ y - z / 2 ] -- ;
ru[ x - 1 ] [ y + z / 2 ] -- ;
ru[ x - z / 2 - 1 ] [ y] ++ ;
ru[ x + z / 2 - 1 ] [ y + 1 ] ++ ;
ru[ x] [ y + z / 2 ] -- ;
ru[ x - 1 ] [ y - z / 2 + 1 ] -- ;
ru[ x - z / 2 ] [ y] ++ ;
}
}
void * ptrs[ 4 ] = { lu, ld, ru, rd} ;
for ( int i = 4004 ; i >= 0 ; -- i) {
for ( int j = 1 ; j <= 4004 ; ++ j) {
for ( auto ptr : ptrs) {
auto p = ( int ( * ) [ N] ) ptr;
p[ i] [ j] + = p[ i + 1 ] [ j - 1 ] + p[ i + 1 ] [ j + 1 ] - p[ i + 2 ] [ j] ;
}
}
}
for ( int i = 4004 ; i >= 0 ; -- i) {
for ( int j = 4004 ; j >= 0 ; -- j) {
ps1[ i] [ j] + = ps1[ i + 1 ] [ j] + ps1[ i] [ j + 1 ] - ps1[ i + 1 ] [ j + 1 ] ;
}
}
int ans = 0 ;
for ( int i = 4004 ; i >= 0 ; -- i) {
for ( int j = 4004 ; j >= 0 ; -- j) {
int t = ( ps1[ i] [ j] ! = 0 ) * 15 ;
if ( lu[ i] [ j] ) t | = 1 | 2 ;
if ( ru[ i] [ j] ) t | = 2 | 4 ;
if ( rd[ i] [ j] ) t | = 4 | 8 ;
if ( ld[ i] [ j] ) t | = 8 | 1 ;
ans + = countBits( t) ;
}
}
cout << fixed;
cout .precision ( 10 ) ;
int ost = ans % 4 ;
cout << ans / 4 ;
if ( ost == 0 ) {
cout << ".00" << endl;
} else if ( ost == 1 ) {
cout << ".25" << endl;
} else if ( ost == 2 ) {
cout << ".50" << endl;
} else {
cout << ".75" << endl;
}
return 0 ;
}
I3ByYWdtYSBjb21tZW50KGxpbmtlciwgIi9zdGFjazoyMDAwMDAwMCIpCi8vI3ByYWdtYSBHQ0Mgb3B0aW1pemUoIk9mYXN0IikKLy8jcHJhZ21hIEdDQyB0YXJnZXQoInNzZSxzc2UyLHNzZTMsc3NzZTMsc3NlNCxwb3BjbnQsYWJtLG1teCxhdngsdHVuZT1uYXRpdmUiKQoKI2RlZmluZSBfQ1JUX1NFQ1VSRV9OT19XQVJOSU5HUwojIGluY2x1ZGUgPGlvc3RyZWFtPgojIGluY2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0dXJuIHJldDsgfQovLyBGYXN0IElPICoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCmNvbnN0IGludCBfX0JTID0gNDA5NjsKc3RhdGljIGNoYXIgX19idXJbX19CUyArIDE2XSwgKl9fZXIgPSBfX2J1ciArIF9fQlMsICpfX2lyID0gX19lcjsKdGVtcGxhdGU8Y2xhc3MgVCA9IGludD4gVCByZWFkSW50KCkgewogICAgYXV0byBjID0gWyZdKCkgeyBpZiAoX19pciA9PSBfX2VyKSBzdGQ6OmZpbGwoX19idXIsIF9fYnVyICsgX19CUywgMCksIGNpbi5yZWFkKF9fYnVyLCBfX0JTKSwgX19pciA9IF9fYnVyOyB9OwogICAgYygpOyB3aGlsZSAoKl9faXIgJiYgKCpfX2lyIDwgJzAnIHx8ICpfX2lyID4gJzknKSAmJiAqX19pciAhPSAnLScpICsrX19pcjsgYygpOwogICAgYm9vbCBtID0gZmFsc2U7IGlmICgqX19pciA9PSAnLScpICsrX19pciwgYygpLCBtID0gdHJ1ZTsKICAgIFQgciA9IDA7IHdoaWxlICgqX19pciA+PSAnMCcgJiYgKl9faXIgPD0gJzknKSByID0gciAqIDEwICsgKl9faXIgLSAnMCcsICsrX19pciwgYygpOwogICAgKytfX2lyOyByZXR1cm4gbSA/IC1yIDogcjsKfQpzdGF0aWMgY2hhciBfX2J1d1tfX0JTICsgMjBdLCAqX19pdyA9IF9fYnV3LCAqX19ldyA9IF9fYnV3ICsgX19CUzsKdGVtcGxhdGU8Y2xhc3MgVD4Kdm9pZCB3cml0ZUludChUIHgsIGNoYXIgZW5kYyA9ICdcbicpIHsKICAgIGlmICh4IDwgMCkgKl9faXcrKyA9ICctJywgeCA9IC14OyBpZiAoeCA9PSAwKSAqX19pdysrID0gJzAnOwogICAgY2hhciogcyA9IF9faXc7CiAgICB3aGlsZSAoeCkgeyBUIHQgPSB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qKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKCmludDMyX3Qgc29sdmUoKTsKaW50MzJfdCBtYWluKGludCBhcmdjLCBjaGFyKiogYXJndikgewogICAgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbygwKTtjaW4udGllKDApOwojaWZkZWYgTE9DQUwKLy8gICAgRlJFSU4oImlucHV0LnR4dCIpOwogICAgLy8gICAgICAgICAgICBGUkVPVVQoIm91dC50eHQiKTsKI2VuZGlmCiAgICByZXR1cm4gc29sdmUoKTsKfQoKY29uc3QgaW50IE4gPSA0MDUwOwppbnQgcHMxW05dW05dOwp1c2luZyBUID0gZGVjbHR5cGUocHMxKTsKVCByZCwgbGQsIGx1LCBydTsKCmludCBzb2x2ZSgpIHsKICAgIGludCBuOwogICAgY2luID4+IG47CiAgICBGSShuKSB7CiAgICAgICAgY2hhciBjOwogICAgICAgIGNpbiA+PiBjOwogICAgICAgIGludCB4LCB5LCB6OwogICAgICAgIGNpbiA+PiB4ID4+IHkgPj4gejsKICAgICAgICB4ICs9IDIwMDI7CiAgICAgICAgeSArPSAyMDAyOwogICAgICAgIGlmIChjID09ICdBJykgewogICAgICAgICAgICB4ICs9IHogLyAyOwogICAgICAgICAgICB5ICs9IHogLyAyOwogICAgICAgICAgICBwczFbeF1beV0rKzsKICAgICAgICAgICAgcHMxW3hdW3kgLSB6XS0tOwogICAgICAgICAgICBwczFbeCAtIHpdW3ldLS07CiAgICAgICAgICAgIHBzMVt4IC0gel1beSAtIHpdKys7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgcmRbeCArIHogLyAyXVt5XSsrOwogICAgICAgICAgICByZFt4XVt5ICsgeiAvIDJdLS07CiAgICAgICAgICAgIHJkW3hdW3kgLSB6IC8gMl0tLTsKICAgICAgICAgICAgcmRbeCAtIHogLyAyXVt5XSsrOwogICAgICAgICAgICAKICAgICAgICAgICAgcmRbeCArIHogLyAyIC0gMV1beV0rKzsKICAgICAgICAgICAgcmRbeCAtIDFdW3kgKyB6IC8gMl0tLTsKICAgICAgICAgICAgcmRbeF1beSAtIHogLyAyICsgMV0tLTsKICAgICAgICAgICAgcmRbeCAtIHogLyAyXVt5ICsgMV0rKzsKICAgICAgICAgICAgCiAgICAgICAgICAgIGxkW3ggKyB6IC8gMl1beSArIDFdKys7CiAgICAgICAgICAgIGxkW3hdW3kgLSB6IC8gMiArIDFdLS07CiAgICAgICAgICAgIGxkW3hdW3kgKyB6IC8gMiArIDFdLS07CiAgICAgICAgICAgIGxkW3ggLSB6IC8gMl1beSArIDFdKys7CiAgICAgICAgICAgIAogICAgICAgICAgICBsZFt4ICsgeiAvIDIgLSAxXVt5ICsgMV0rKzsKICAgICAgICAgICAgbGRbeF1beSArIHogLyAyXS0tOwogICAgICAgICAgICBsZFt4IC0gMV1beSAtIHogLyAyICsgMV0tLTsKICAgICAgICAgICAgbGRbeCAtIHogLyAyXVt5XSsrOwogICAgICAgICAgICAKICAgICAgICAgICAgbHVbeCArIHogLyAyIC0gMV1beV0rKzsKICAgICAgICAgICAgbHVbeF1beSAtIHogLyAyICsgMV0tLTsKICAgICAgICAgICAgbHVbeCAtIDFdW3kgKyB6IC8gMl0tLTsKICAgICAgICAgICAgbHVbeCAtIHogLyAyXVt5ICsgMV0rKzsKICAgICAgICAgICAgCiAgICAgICAgICAgIGx1W3ggKyB6IC8gMiAtIDFdW3kgKyAxXSsrOwogICAgICAgICAgICBsdVt4IC0gMV1beSArIHogLyAyICsgMV0tLTsKICAgICAgICAgICAgbHVbeCAtIDFdW3kgLSB6IC8gMiArIDFdLS07CiAgICAgICAgICAgIGx1W3ggLSB6IC8gMiAtIDFdW3kgKyAxXSsrOwogICAgICAgICAgICAKICAgICAgICAgICAgcnVbeCArIHogLyAyIC0gMV1beV0rKzsKICAgICAgICAgICAgcnVbeCAtIDFdW3kgLSB6IC8gMl0tLTsKICAgICAgICAgICAgcnVbeCAtIDFdW3kgKyB6IC8gMl0tLTsKICAgICAgICAgICAgcnVbeCAtIHogLyAyIC0gMV1beV0rKzsKICAgICAgICAgICAgCiAgICAgICAgICAgIHJ1W3ggKyB6IC8gMiAtIDFdW3kgKyAxXSsrOwogICAgICAgICAgICBydVt4XVt5ICsgeiAvIDJdLS07CiAgICAgICAgICAgIHJ1W3ggLSAxXVt5IC0geiAvIDIgKyAxXS0tOwogICAgICAgICAgICBydVt4IC0geiAvIDJdW3ldKys7CiAgICAgICAgfQogICAgfQogICAgdm9pZCogcHRyc1s0XSA9IHtsdSwgbGQsIHJ1LCByZH07CiAgICBmb3IgKGludCBpID0gNDAwNDsgaSA+PSAwOyAtLWkpIHsKICAgICAgICBmb3IgKGludCBqID0gMTsgaiA8PSA0MDA0OyArK2opIHsKICAgICAgICAgICAgZm9yIChhdXRvIHB0ciA6IHB0cnMpIHsKICAgICAgICAgICAgICAgIGF1dG8gcCA9IChpbnQoKilbTl0pcHRyOwogICAgICAgICAgICAgICAgcFtpXVtqXSArPSBwW2kgKyAxXVtqIC0gMV0gKyBwW2kgKyAxXVtqICsgMV0gLSBwW2kgKyAyXVtqXTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KICAgIGZvciAoaW50IGkgPSA0MDA0OyBpID49IDA7IC0taSkgewogICAgICAgIGZvciAoaW50IGogPSA0MDA0OyBqID49IDA7IC0taikgewogICAgICAgICAgICBwczFbaV1bal0gKz0gcHMxW2kgKyAxXVtqXSArIHBzMVtpXVtqICsgMV0gLSBwczFbaSArIDFdW2ogKyAxXTsKICAgICAgICB9CiAgICB9CiAgICBpbnQgYW5zID0gMDsKICAgIGZvciAoaW50IGkgPSA0MDA0OyBpID49IDA7IC0taSkgewogICAgICAgIGZvciAoaW50IGogPSA0MDA0OyBqID49IDA7IC0taikgewogICAgICAgICAgICBpbnQgdCA9IChwczFbaV1bal0gIT0gMCkgKiAxNTsKICAgICAgICAgICAgaWYgKGx1W2ldW2pdKSB0IHw9IDEgfCAyOwogICAgICAgICAgICBpZiAocnVbaV1bal0pIHQgfD0gMiB8IDQ7CiAgICAgICAgICAgIGlmIChyZFtpXVtqXSkgdCB8PSA0IHwgODsKICAgICAgICAgICAgaWYgKGxkW2ldW2pdKSB0IHw9IDggfCAxOwogICAgICAgICAgICBhbnMgKz0gY291bnRCaXRzKHQpOwogICAgICAgIH0KICAgIH0KICAgIGNvdXQgPDwgZml4ZWQ7CiAgICBjb3V0LnByZWNpc2lvbigxMCk7CiAgICBpbnQgb3N0ID0gYW5zICUgNDsKICAgIGNvdXQgPDwgYW5zIC8gNDsKICAgIGlmIChvc3QgPT0gMCkgewogICAgICAgIGNvdXQgPDwgIi4wMCIgPDwgZW5kbDsKICAgIH0gZWxzZSBpZiAob3N0ID09IDEpIHsKICAgICAgICBjb3V0IDw8ICIuMjUiIDw8IGVuZGw7CiAgICB9IGVsc2UgaWYgKG9zdCA9PSAyKSB7CiAgICAgICAgY291dCA8PCAiLjUwIiA8PCBlbmRsOwogICAgfSBlbHNlIHsKICAgICAgICBjb3V0IDw8ICIuNzUiIDw8IGVuZGw7CiAgICB9CiAgICByZXR1cm4gMDsKfQoK