#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
 
int dx[] = {0, -1, -1, 0, 1, 1};
int dy[] = {-1, -1, 0, 1, 1, 0};

typedef pair<int, int> P; 

vector<P> move(int d, vector<int> m){
  int x = 0, y = 0;
  int mx = 0, my = 0;
  vector<P> path;
  path.push_back(P(0, 0));
  for(int i = 0 ; i < (int)m.size() ; i++){
    x += dx[ (m[i]+d)%6 ] ,y += dy[ (m[i]+d)%6 ];
    mx = min(mx, x), my = min(my, y);
    path.push_back(P(x, y));
  }
  sort(path.begin(), path.end());
  for(int i = 0 ; i < (int)path.size() ; i++){
    path[i].first -= mx, path[i].second -= my;
  }
  return path;
}

bool solve(vector<int> m1, vector<int> m2){
  vector<P> path1 = move(0, m1);
  
  for(int i = 0 ; i < 6 ; i++){
    vector<P> path2 = move(i, m2);
    if(path1 == path2) return true;
  }
  return false;
}
int main(){
  int n;
  cin >> n;
  cin.ignore();
  string s1, s2, tmp;
  for(int i = 0 ; i < n ; i++){
    getline(cin, s1);
    getline(cin, s2);
    getline(cin, tmp);
 
    vector<int> m1, m2;
    for(int i = 0 ; i < (int)s1.size() ; i++) m1.push_back(s1[i]-'a');
    for(int i = 0 ; i < (int)s2.size() ; i++) m2.push_back(s2[i]-'a');
    
    if(solve(m1, m2)) cout << "true" << endl;
    else cout << "false" << endl;
  }
  return 0;
}