import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuffer sb = new StringBuffer("");
int avaibleIt[][] = {{0, 1, 2, 3, 4, 5}, {0, 1, 3, 4, 5, 2}, {0, 1, 5, 2, 3, 4},
{0, 1, 4, 5, 2, 3}, {1, 0, 4, 3, 2, 5}, {1, 0, 3, 2, 5, 4},
{1, 0, 2, 5, 4, 3}, {1, 0, 5, 4, 3, 2}, {4, 2, 0, 3, 1, 5},
{4, 2, 3, 1, 5, 0}, {4, 2, 1, 5, 0, 3}, {4, 2, 5, 0, 3, 1},
{2, 4, 1, 3, 0, 5}, {2, 4, 3, 0, 5, 1}, {2, 4, 0, 5, 1, 3},
{2, 4, 5, 1, 3, 0}, {5, 3, 2, 0, 4, 1}, {5, 3, 0, 4, 1, 2},
{5, 3, 4, 1, 2, 0}, {5, 3, 1, 2, 0, 4}, {3, 5, 2, 1, 4, 0},
{3, 5, 1, 4, 0, 2}, {3, 5, 4, 0, 2, 1}, {3, 5, 0, 2, 1, 4}};
String m = "";
int cases=Integer.parseInt(br.readLine());
for(int z=0;z<cases;z++){
String []str=br.readLine().split(" ");
char[] x = str[0].toCharArray(), y = str[1].toCharArray();
if(cubeRotation(avaibleIt, x, y)){
sb.append("Equal").append("\n");
}else{
sb.append("Not Equal").append("\n");
}
}
System.out.print(sb);
}
static boolean cubeRotation(int[][] arr, char[] x, char[] y) {
char[] temp = new char[6];
for (int i = 0; i < 24; i++) {
for (int j = 0; j < 6; j++) {
temp[j] = x[arr[i][j]];
}
if (compareChars(temp, y)) {
return true;
}
}
return false;
}
static boolean compareChars(char[] x, char[] y) {
for (int i = 0; i < x.length; i++) {
if (x[i] != y[i]) {
return false;
}
}
return true;
}
}
No comments:
Post a Comment