Prefix and Suffix

Limits 2s, 256 MB

Initially, you are given an empty array AAA. You have to perform the following queries.


This is a companion discussion topic for the original entry at https://toph.co/p/prefix-and-suffix