#include <stdio.h>

#define ALEN (26)

int perm[30];
int vis[30];
int cycle[30];

typedef long long int64;

int main()
{
  int n,i,k;
  int64 mult,bin,ik,sum;
  int size;
  char buf[30];
  
  scanf("%d",&n);
  while(n--)
  {
    scanf("%s",buf);
    for (i=0;i<ALEN;i++)
    {
      int tmp=buf[i]-'A';
      perm[i]=tmp;
      vis[i]=0;
    }
    
    // Count cycles
    for (i=0;i<ALEN+1;i++) cycle[i]=0;
    
    for (i=0;i<ALEN;i++)
      if (!vis[i])
      {
        int tmp=perm[i];
        size=1;  
        vis[i]=1;
        while (i!=tmp)
        {
          vis[tmp]=1;
          tmp=perm[tmp];
          size++;
        }
        cycle[size]++;
      }

    sum=1;
    for (i=1;i<ALEN+1;i++)
    {
      if (cycle[i]==0) mult=1;
      else
      if (!(i&1)) // Even cycles
      {
        if ((cycle[i] & 1)) mult=0; 
        else
        {
          bin=1;ik=1;
          for (k=0;k<cycle[i]/2;k++)
          {
            bin*=(cycle[i]-2*k)*(cycle[i]-2*k-1);
            bin/=(2*(k+1));
            ik*=i;
          } 
          mult=bin*ik;
        } 
      }
      else // Odd cycle 
      {
        mult=1;
        bin=1;ik=1; 
        for (k=0;k<cycle[i]/2;k++)
        {
          bin*=(cycle[i]-2*k)*(cycle[i]-2*k-1);
          bin/=(2*(k+1));
          ik*=i;
          mult+=bin*ik;
        }
      }
      sum*=mult;
    }
    if (sum)
      printf("Yes\n");
    else
      printf("No\n");  
   
  }
  return 0;
}
