Equivalent Suffix Tries

All submissions for this problem are available.
Suffix trees are very powerful data structures. Using suffix trees it's often easy to solve the hardest computer science problems on strings. In this problem we'll consider a simplified version of suffix trees  suffix tries (that is, tries formed by all suffixes of a given string).
Generally, the suffix tree is a tree whose edges are labeled with strings. Instead, we'll only consider suffix tries whose edges are labeled with single characters. This way every edge of a suffix tree may correspond to one or more edges connected in a chainstyle fashion of a suffix trie.
Another trait of suffix trees is that each suffix of the string for which the suffix tree is built corresponds to exactly one path from the tree's root to a leaf. This is usually achieved by terminating each suffix of the string with a special character, say, $. However, in suffix tries we won't do that. In particular, this implies that the number of leaves in a suffix trie can be smaller than the length of the original string.
In the picture the suffix tries for strings 'aba' and 'abac' are presented:
If we erase all letters from the edges of a suffix trie, it actually becomes a directed graph. Let's call two suffix tries equivalent if their corresponding directed graphs are isomorphic.
You're given a single string consisting of lowercase Latin letters. Your task is to find the number of different strings of the same length consisting of lowercase Latin letters as well such that their suffix tries are equivalent to the suffix trie of the given string. As this number can be large enough, output the remainder of its division by 42424242.
Input
The first line contains a single number T  the number of test cases (no more than 10). Each of the next T lines contains a single nonempty string of length no more than 100000 consisting of lowercase Latin letters a..z.
Output
For each test case output just one line containing the sought number modulo 42424242.
Example
Input: 5 a aa abc aba helloworld Output: 26 26 15600 1300 6221124 Explanation:
In the first test case every string of length 1 satisfies the condition. In the second test case every string consisting of two equal letters is fine. In the third test case every string comprising three pairwise distinct letters adds 1 to the answer. In the fourth test case string 'bee' is one of the 1300 good strings.
Author:  gennady.korotkevich 
Tester:  laycurse 
Editorial  http://discuss.codechef.com/problems/EST 
Tags  gennady.korotkevich, hard, hashing, july12, strings 
Date Added:  6062012 
Time Limit:  0.476583 sec 
Source Limit:  50000 Bytes 
Languages:  C, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions