Honggik University
InterviewTime limit1sMemory limit1024 MB
Count the ways to split a word into contiguous segments that each contain exactly one vowel, modulo 10^9+7, or print -1 if the word has no vowels.
Problem
The English name of Hongik University is hongik university. However, some readers pronounce it as hon/gik instead of hong/ik, which turns it into the unintended name Honggik University (혼긱대학교), and this happens often enough to be funny.
Donghyun noticed that a word's pronunciation changes depending on whether a consonant attaches to the vowel before it or the vowel after it. He wants to find out how many different ways similar English words can be pronounced. Since he is weak at English, he only uses the rules below to work out pronunciations.
- English has 5 vowels,
a,e,i,o, andu. The consonants are the other 21 letters of the alphabet. - One vowel can have zero or more consonants attached before and after it to form one sound. The sounds together form the pronunciation of the word.
- Example:
h, o, n, g, i, k → hong, ik → hongik
- Example:
- A consonant can join a consonant or a vowel into one sound only when they are adjacent.
- Sounds with a different number, makeup, or order of letters are treated as different sounds.
- Example:
ab,abb, andbaare all different sounds.
- Example:
- Each letter of the given word must be used exactly once to form the pronunciation.
- If the composition of the sounds differs, the pronunciations of the word are counted as different.
Following these rules, output the number of ways the word can be pronounced.
Input
The first line contains the number of test cases .
Each of the next lines contains a word made of lowercase English letters.
The total length of all words is at most .
Output
For each test case, print the number of ways the word can be pronounced, modulo , on its own line.
If the word has no vowels and cannot be pronounced, print -1.
Hint
hongik can be pronounced in 3 ways: ho/ngik, hon/gik, and hong/ik.