Roy and Birthday
Approved
Combinatorics
Easy
Implementation
Math
Open
78.0% success
12,130 attempts
1s time
256MB memory
1024KB max code

Its Roy's birthday and he is decorating his house with balloons.
He has 26 different types of balloons. They are represented by [a-z].

Now Roy does not want to have few particular balloons together. Actually he doesn't want to keep any of the two vowel (i.e [a,e,i,o,u] ) balloons together.
So, in one arrangement no two vowels should be together. Given the string of balloons there can be many such arrangements possible.
Help Roy in finding the number of possible arrangements.

Number of such arrangements can be quite large, so print it modulo 1000000007 (109 + 7)
Also, there's a chance that no such arrangement is possible. Print "-1" in such cases (without quotes)

Input:
First line contains T, number of test cases.
Each of next T lines contains a string composed of lower case letters representing all the balloons.

Output:
For each test case print the required answer.

Constraints:
1 <= T <= 100
1 <= Length of string <= 1000000 (106)

Note: Sum of string lengths over all the test cases in one file does not exceed 1000000 (106)

Examples
Input
2
abe
ae
Output
2
-1
Explanation

Test #1: Possible arrangements are [1] abe [2] eba

Test #2: There are no any arrangements possible such that any two vowels are not together. So print -1.

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading Editor...