Gifted Composer
题号:NC52293
时间限制:C/C++/Rust/Pascal 8秒,其他语言16秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
64bit IO Format: %lld

题目描述

Acesrc is a gifted composer. He likes writing tuneful and melodic songs. Every song he writes can be viewed as a sequence of musical notes, and each musical note represents the pitch and the duration of the sound. In this problem, we consider only the following seven primary pitches
do re mi fa sol la si
and the duration of each note is one unit time. Hence, there are only seven types of notes, and we may use the pitch name to represent a note.

Acesrc composes a song in the following way. Initially, the sequence of notes is empty. Every day, he inserts a new note at the beginning or at the end of the sequence, until the song is done.

Acesrc particularly likes songs with repetitions. For a song with n musical notes, we say the song has a repetition of length k , if the song can be partitioned into one or more identical sections with k notes, optionally followed by an incomplete section, which is an initial part of a complete section. For example, can be partitioned into , so it has a repetition of length 2; similarly, has a repetition of length 3, and has a repetition of length 5.

Acesrc wants to know, after he adds a note each day, the number of different lengths of repetitions the song has. Can you help him?

输入描述:

The first line of input consists of a single line n , the number of days Acesrc uses to compose the song. The ith of the remaining n lines contains a character a  (where \texttt{p} denotes prepend, i.e., inserting at the beginning, and \texttt{a} denotes append, i.e., inserting at the end) and a string s , representing the action Acesrc takes in the ith day.

输出描述:

Output n lines. The ith line should be a single integer, denoting the answer for the ith day.
示例1

输入

复制
5
a do
p re
a re
a do
p do

输出

复制
1
1
2
2
3
示例2

输入

复制
5
a re
a do
a re
p do
a mi

输出

复制
1
1
2
2
1