Vasya became interested in bioinformatics. He's going to write an article about similar cyclic DNA sequences, so he invented a new method for determining the similarity of cyclic sequences.
Let's assume that strings s and t have the same length n, then the function h(s,?t) is defined as the number of positions in which the respective symbols of s and t are the same. Function h(s,?t) can be used to define the function of Vasya distance ¦Ñ(s,?t):
Vasya found a string s of length n on the Internet.
Now he wants to count how many strings t there are such that the Vasya distance from the string s attains
maximum possible value. Formally speaking, t must satisfy the equation: .<†·Ÿ"/kf/ware/vc/" target="_blank" class="keylink">vcD4KPHA+ClZhc3lhIGNvdWxkIG5vdCB0cnkgYWxsIHBvc3NpYmxlIHN0cmluZ3MgdG8gZmluZCBhbiBhbnN3ZXIsIHNvIGhlIG5lZWRzIHlvdXIgaGVscC4gQXMgdGhlIGFuc3dlciBtYXkgYmUgdmVyeSBsYXJnZSwgY291bnQgdGhlIG51bWJlciBvZiBzdWNoIHN0cmluZ3MgbW9kdWxvIDEwOT8mIzQzOz83LjwvcD4KCgoKSW5wdXQKPHA+ClRoZSBmaXJzdCBsaW5lIG9mIHRoZSBpbnB1dCBjb250YWlucyBhIHNpbmdsZSBpbnRlZ2VyIDxlbT5uPC9lbT4gKDE/odw/PGVtPm48L2VtPj+h3D8xMDUpLjwvcD4KPHA+ClRoZSBzZWNvbmQgbGluZSBvZiB0aGUgaW5wdXQgY29udGFpbnMgYSBzaW5nbGUgc3RyaW5nIG9mIGxlbmd0aCA8ZW0+bjwvZW0+LCBjb25zaXN0aW5nIG9mIGNoYXJhY3RlcnMg"ACGT".
Print a single number ¡ª the answer modulo 109?+?7.
Sample test(s) input1 Coutput
1input
2 AGoutput
4input
3 TTToutput
1Note
Please note that if for two distinct strings t1 and t2 values ¦Ñ(s,?t1) §Ú ¦Ñ(s,?t2) are maximum among all possible t, then both strings must be taken into account in the answer even if one of them can be obtained by a circular shift of another one.
In the first sample, there is ¦Ñ("C",?"C")?=?1, for the remaining strings t of length 1 the value of ¦Ñ(s,?t) is 0.
In the second sample, ¦Ñ("AG",?"AG")?=?¦Ñ("AG",?"GA")?=?¦Ñ("AG",?"AA")?=?¦Ñ("AG",?"GG")?=?4.
In the third sample, ¦Ñ("TTT",?"TTT")?=?27
´úÂ룺
#include#include #include #include #include #include #include