In the example for the first query of the second type, the segment looks like , meaning there are numbers , , and , are equal to , so the answer is . After the next query of type , becomes , so for the next query, the answer is . After the next query, the array will look like . In the last query, the segment will look like , meaning there are numbers , respectively the answer is , because .
Scoring
( points): ;
( points): only queries of type ; ; ;
( points): only queries of type ;
( points): only queries of type and ; all are pairwise distinct;
( points): only queries of type and ; all can change only once;