{-
URL: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1142&lang=jp
?????????: Organize Your Train part II
????\???????:
20:02:00 C++??????????????????
20:03:00 ????????????????????????
20:03:30 ?????????Haskell??§?????????????????????????????¨??????
20:04:30 Haskell????????????????????? 
20:12:31 ???????????????
20:13:10 ??????????????????
-}
import Control.Monad
import qualified Data.Set as S

main = do
 m <- fmap read getLine
 sequence_ $ replicate m action

action = do
 str <- getLine
 print $ solve str

solve :: String -> Int
solve = S.size . S.fromList . cands 

cands :: String -> [String]
cands str = do
 (a,b) <- splitter str
 a' <- [a, reverse a]
 b' <- [b, reverse b]
 [a' ++ b', b' ++ a']

splitter :: String -> [(String, String)]
splitter [] = [([],[])]
splitter (x:xs) = ([], x:xs) : [(x:a, b) | (a,b) <- splitter xs]