An ecosystem initially contains distinct types of viruses. The structure of virus is represented by an uppercase English string . Viruses of different types remain distinct even if their structures are identical.
The similarity of two viruses is the length of the longest common prefix of their structure strings. The extinction risk of an ecosystem is the sum of these similarities over all unordered pairs of distinct virus types.
The ecosystem undergoes changes in order. Each change is represented by an uppercase letter followed by one digit , written as . Apply a change in the following order.
Removing a character may produce an empty string. An empty string does not start with any letter and has similarity with every string. Newly added viruses participate in all subsequent changes.
After each change, find the absolute difference between the extinction risk computed using all virus types currently present and the extinction risk computed using only the original virus types. Both risks use the structures at that point in time.
The input is given in the following format:
Print space-separated integers on one line. The -th integer must be the absolute difference between the two extinction risks after change .
After the first change, the two original structures are the empty string and . The two new virus types both have structure . The full extinction risk is , while the risk using only the original types is .
After the second change, the structures are , , the empty string, and the empty string, respectively. Both extinction risks are .
The string has length and concatenates all changes without spaces. For change , the mutation letter is , and the number of new virus types is the digit at .
0 through 9 ().| 2 | 8 | . |
| 3 | 11 | Every uppercase letter in the input is . |
| 4 | 17 | Every uppercase letter in the input is one of . |
| 5 | 9 | Every uppercase letter in the input is one of . |
| 6 | 16 | After all changes, the number of virus types is . |
| 7 | 33 | No additional constraints. |
After the first change, both original viruses have structure . They remain distinct types even though their structures are now identical.