A subarray of an array $$$B$$$ is a contiguous sequence of elements taken from $$$B$$$. For example, if $$$B=[3,1,4,1,5]$$$, then $$$[3,1,4]$$$, $$$[4,1]$$$, the empty array $$$[\ ]$$$ and the whole array $$$B$$$ are subarrays of $$$B$$$ (among others), while $$$[3,4,5]$$$ and $$$[1,3]$$$ are not subarrays of $$$B$$$.
We also define $$$C^m$$$ as the array obtained by the concatenation of $$$m$$$ copies of the array $$$C$$$. For example, if $$$C=[3,2]$$$ then $$$C^1=[3,2]$$$, $$$C^2=[3,2,3,2]$$$ and $$$C^{\infty}=[\ldots,3,2,3,2,3,2,\ldots]$$$.
In this problem you are given an array $$$P$$$ containing no repeated numbers, and you have to process a sequence of events that occur in order. The events can be of three types:
Are you ready for this challenge?
The first line contains an integer $$$N$$$ ($$$1 \leq N \leq 5 \cdot 10^5$$$) indicating the initial length of $$$P$$$.
The second line contains $$$N$$$ different integers $$${P_1}, {P_2}, \ldots, {P_N}$$$ ($$$1 \leq P_i \leq 10^6$$$ for $$${i}={1}, {2}, \ldots, {N}$$$).
The third line contains an integer $$$E$$$ ($$$1 \leq E \leq 5 \cdot 10^5$$$) representing the number of events that need to be processed.
Each of the next $$$E$$$ lines describes an event, in the order they must be processed. The content of the line depends on the event, as follows:
Output a line for each query, with an integer indicating the length of the longest common subarray between $$$P^\infty$$$ and $$$A^\infty$$$, or the character '*' (asterisk) if the length of the longest common subarray is larger than $$$10^{18}$$$.
4 1 2 3 4 10 ? 2 3 2 ? 3 99 99 99 - 1 - 4 ? 2 3 3 ? 3 4 1 4 + 64 3 + 1 2 ? 4 1 2 64 3 ? 4 1 3 64 2
2 0 1 0 * 1
1 217 1 ? 1 314
0