[Cpp]
# Include <cstdlib>
# Include <iostream>
# Include <cstdio>
# Include <cmath>
# Include <set>
# Include <cstring>
# Include <algorithm>
# Define inf 0x7fffffff
# Define N 1000
# Define MIN 1e-11
# Define M 10001
# Define MM 20020
# Define LL long
Using namespace std;
Int n, t, k;
Char str [105];
Int al [130];
Int main ()
{
# Ifndef ONLINE_JUDGE
Freopen ("ex. in", "r", stdin );
# Endif
Scanf ("% d % * c", & t );
While (t --)
{
Memset (al, 0, sizeof (al ));
Gets (str );
Int OK = 1, cnt = 0;
Int len = strlen (str );
Int l = len/2;
Len-= 1;
Int first = 1;
For (int I = 0; I <l; I ++)
{
Int flag = 0;
Int j = len;
For (; j> I; j --)
{
If (str [I] = str [j])
{
Flag = 1;
Break;
}
}
If (! Flag & (first | al [str [I])
{
Al [str [I] = 1;
Swap (str [I], str [I + 1]);
Cnt ++;
I --;
First = 0;
Continue;
}
If (! Flag &&! First)
{
OK = 0;
Break;
}
If (j! = Len)
{
Cnt + = len-j;
Char c = str [j];
For (int k = j + 1; k <= len; k ++)
Str [k-1] = str [k];
Str [len] = c;
}
Len --;
}
If (OK)
Printf ("% d \ n", cnt );
Else
Printf ("Impossible \ n ");
}
Return 0;
}