Roy and Birthday
Practice
4.5 (32 votes)
Approved
Combinatorics
Easy
Implementation
Math
Open
Problem
78% Success 12037 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB 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)

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...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
54 votes
Tags:
AlgorithmsApprovedEasyOpen
Points:20
187 votes
Tags:
ApprovedEasyMathNumber TheoryOpen
Points:20
56 votes
Tags:
Ad-HocAlgorithmsApprovedEasyOpen