#include #include #include #include using namespace std; typedef pair duint; const int dx[6] = { +1, +1, 0, -1, -1, 0 }; const int dy[6] = { 0, +1, +1, 0, -1, -1 }; bool determine(string s, string t) { set S; int x, y; x = y = 0; for(int i = 0; i < s.length(); i++) { x += dx[s[i] - 'a']; y += dy[s[i] - 'a']; S.insert(make_pair(x, y)); } for(int j = 0; j < 6; j++) { set T; x = y = 0; for(int i = 0; i < t.length(); i++) { x += dx[(t[i] - 'a' + j) % 6]; y += dy[(t[i] - 'a' + j) % 6]; T.insert(make_pair(x, y)); } if(S == T) return true; T.clear(); } return false; } int main(void) { ifstream cin("hive.txt"); int n; cin >> n; for(int i = 0; i < n; i++) { string s, t, dmy; cin >> s >> t >> dmy; cout << (determine(s, t) ? "true" : "false") << endl; } return 0; }