rendered paste body#include <map>
#include <iostream>
using namespace std;
#define DBG
#ifdef DBG
#define D(x) x
#define DP(x) cout<<x<<endl;
#else
#define D(x)
#define DP(x)
#endif
enum { NOTEQ = 0, EQ, REFL };
class Coord
{
public :
inline Coord (const Coord &inp) {
this->pt[0] = inp.pt[0];
this->pt[1] = inp.pt[1];
this->pt[2] = inp.pt[2];
}
inline Coord ( int x=0, int y=0, int z=0) {
pt[0] = x,pt[1] = y, pt[2] = z;
}
inline Coord operator >> ( int n) {
Coord ans(*this);
while(n--) {
int tmp;
tmp= pt[2], pt[2] = pt[1], pt[1] = pt[0], pt[0] = tmp;
}
return ans;
}
inline Coord operator << ( int n) {
Coord ans(*this);
while(n--) {
int tmp;
tmp= pt[0], pt[0] = pt[1], pt[1] = pt[2], pt[2] = tmp;
}
return ans;
}
inline Coord operator ^ (Coord b) {
int new_pt[3];
pt[0] = this->pt[0] | b.pt[0]?0:1;
pt[1] = this->pt[1] | b.pt[1]?0:1;
pt[2] = this->pt[2] | b.pt[2]?0:1;
return Coord(pt[0], pt[1], pt[2]);
}
inline Coord operator -() {
return Coord (-pt[0], -pt[1], -pt[2] );
}
inline int operator[] (int x) {
return pt[x%3];
}
inline bool operator == (Coord inp) {
return this->pt[0] == inp.pt[0] && this->pt[1] == inp.pt[1] && this->pt[2] == inp.pt[2];
}
inline bool operator <(const Coord inp)const {
if (this->pt[0] < inp.pt[0])
return true;
else if (this->pt[0] == inp.pt[0]) {
if (this->pt[1] < inp.pt[1])
return true;
else if (this->pt[1] == inp.pt[1]) {
if (this->pt[2] < inp.pt[2])
return true;
}
}
return false;
}
// exactly two of a,b,c have to be 1 to satisfy perpendicularity
inline bool operator && (const Coord b) const {
long p, q, r;
p = this->pt[0] || b.pt[0];
q = this->pt[1] || b.pt[1];
r = this->pt[2] || b.pt[2];
return !(p^q^r);
}
private :
int pt[3];
};
class Dice
{
private :
map<Coord, int > val;
public:
Dice (int inp[6]) {
val [Coord(0, 1, 0)] = inp[0];
val [Coord(-1, 0, 0)] = inp[1];
val [Coord(0, 0, 1)] = inp[2];
val [Coord(1, 0, 0)] = inp[3];
val [Coord(0, -1, 0)] = inp[4];
val [Coord(0, 0, -1)] = inp[5];
}
inline Coord find (int inp) {
for ( map<Coord, int>::iterator iter = val.begin(); iter != val.end(); iter++) {
if ( iter->second == inp)
return iter->first;
}
return Coord(0,0,0);
}
inline int operator [] (Coord inp) {
return val[inp];
}
inline int operator () (int a, int b, int c) {
return val [Coord(a, b, c)];
}
};
char * compare (Dice a, Dice b)
{
Coord t_right = b.find(a(1, 0, 0));
Coord t_top = b.find(a(0, 1, 0));
Coord t_front = b.find(a(0, 0, 1));
Coord t_null = Coord(0, 0, 0);
if ( t_right == t_null || a(-1, 0, 0) != b[-t_right] ||
t_top == t_null || a(0, -1, 0) != b[-t_top] ||
t_front == t_null || a(0, 0, -1) != b[-t_right]
) {
D(cout<<"Basic Test Failed"<<endl);
return "NOTEQ";
}
/*
if ( a(0, 0, 1) == b[t_right<<1] && a(0, 0, -1) == b[-t_right<<1] ) {
D(cout<<"Up Test Passed"<<endl);
if ( a(0, 1, 0) == b[t_right>>1] && a(0, -1, 0) == b[-t_right>>1] )
return "EQ";
else if (a(0, 1, 0) == b[-t_right>>1] && a(0, -1, 0) == b[t_right>>1])
return "REFL";
else
return "NOTEQ";
}
else if ( a(0, 0, 1) == b[-t_right<<1] && a(0, 0, -1) == b[t_right<<1] ) {
D(cout<<"Up Test Failed"<<endl);
if ( a(0, 1, 0) == b[t_right>>1] && a(0, -1, 0) == b[-t_right>>1] )
return "REFL";
else
return "NOTEQ";
}
else
return "NOTEQ";
*/
}
int main()
{
int tmp[6],
i;
for (i=0; i<6; i++)
cin>>tmp[i];
Dice a(tmp);
for (i=0; i<6; i++)
cin>>tmp[i];
Dice b(tmp);
cout<<compare(a, b)<<endl;
return 0;
}