| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 512 MB | 12 | 7 | 4 | 44.444% |
Let us transform the sequence of positive integers 1,ドル 2, 3, \ldots$ in the following way:
FizzBuzz",Fizz",Buzz"The beginning of the sequence will look as follows:
1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz 16 17 Fizz ...
Consider the infinite string $F$ obtained by writing this sequence without spaces. Given a string $L,ドル find whether it appears as substring of $F,ドル and if it appears, find the 1-based index of first appearance.
First line of the input contains one integer $N,ドル the number of test cases (1ドル \le N \le 20$). Each of the next $N$ lines contains one non-empty string $L$ composed from digits and letters "F", "B", "i", "u", and "z". The length of this string does not exceed 15ドル$.
For each test case, print $-1$ if the given string $L$ does not appear in $F$ as a substring, or the smallest possible 1-based index of its first element in $F$ if it appears.
6 1 78Fizz 68FizzBuzz71 FizzBu uzzBuz 987654321
1 16 208 18 -1 8358189296