#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
vector<int> ss(string&s ){
  vector<int> v;
  for(int i=0;i<(int)s.size();i++){
    v.push_back( s[i] - 'a' );
  }
  return v;
}

int dx[2][6]={ {0,-1,-1,0,1,1},
               {0,1,1,0,-1,-1} };
int dy[2][6]={ {1,1,0,-1,-1,0},
               {1,0,-1,-1,0,1} };

void dfs(int x,int y,int c,int k,const vector<int>& v,set<P> &s){
  s.insert(P(x,y));
  if( c == (int)v.size() ) return;
  int d = (v[c]+k)%6;
  dfs( x + dx[0][d], y + dy[0][d], c+1, k, v, s );
}

bool eq(const set<P>& a, const set<P>& b){
  if(a.size() != b.size() ) return false;
  for( auto x = a.begin(), y = b.begin(); x != a.end() || y != b.end(); x++, y++ )
    if( *x != *y ) return false;
  return true;
}

void view(const set<P> &s ){
  for( auto x : s ){
    cout << x.first << " " <<x.second << endl;
  }
}

int main(){

  int T;
  cin >> T;
  getchar();
  while(T--){
    string S1,S2; 
    getline(cin,S1);
    getline(cin,S2);
    vector<int> v1 = ss( S1 ), v2 = ss( S2 );
    getline(cin,S1);   
    bool f = false;
    for(int i=0;i<6;i++){
      set<P> s1;
      dfs( 0,0,0,i,v1,s1 );
      //cout << "s1------------- "<< endl;
      // view(s1);
      for(int j=0;j<6;j++){
        for( auto ps : s1 ){
          set<P> s2;
          dfs(ps.first,ps.second,0,j,v2,s2);
          //cout << "s2 "<< endl;
          //view(s2);
          if( eq(s1, s2) ) {
            //cout << "ok---------" << endl;
            f = true;
          }
        }
      }      
    }
    if( f ) cout << "true" << endl;
    else cout << "false" << endl;
  }
}