Problem: In Morse code, an letter of English alphabet is represented as a string of some length from to . Moreover, each Morse code representation of an English letter contains only dots and dashes. In this task, we will represent a dot with a "0" and a dash with a "1".
Because there are strings with length to containing only "0" and/or "1", not all of them correspond to one of the English letters. In particular, each string of "0" and/or "1" of length at most translates into a distinct English letter, except the following four strings that do not correspond to any English alphabet: "0011", "0101", "1110", and "1111".
You will work with a string , which is initially empty. For times, either a dot or a dash will be appended to , one at a time. Your task is to find and report, after each of these modifications to string , the number of non-empty sequences of English letters that are represented with some substring of in Morse code.
Since the answers can be incredibly tremendous, print them modulo .
Input Format: The first line contains an integer () — the number of modifications to .
Each of the next lines contains either a "0" (representing a dot) or a "1" (representing a dash), specifying which character should be appended to .
Output Format: Print lines, the -th of which being the answer after the -th modification to .
Note: Let us consider the first sample after all characters have been appended to , so S is "111".
As you can see, "1", "11", and "111" all correspond to some distinct English letter. In fact, they are translated into a 'T', an 'M', and an 'O', respectively. All non-empty sequences of English letters that are represented with some substring of in Morse code, therefore, are as follows.
- "T" (translates into "1")
- "M" (translates into "11")
- "O" (translates into "111")
- "TT" (translates into "11")
- "TM" (translates into "111")
- "MT" (translates into "111")
- "TTT" (translates into "111")
Although unnecessary for this task, a conversion table from English alphabets into Morse code can be found here.