RCC 2014 Warmup (Div. 1)
E
Tricky Password
Codeforces
3100
原题
← D→
翻译中…

In order to ensure confidentiality, the access to the "Russian Code Cup" problems is password protected during the problem development process.

翻译中…

To select a password, the jury can generate a special table that contains $*n*$ columns and the infinite number of rows. To construct a table, the first row is fixed, and all the others are obtained by the following rule:

翻译中…

In the row $*i*$ at position $*p*$ there is a number equal to the number of times $*a*[*i* - 1][*p*]$ occurs on the prefix $*a*[*i* - 1][1... *p*]$.

翻译中…

To ensure the required level of confidentiality, the jury must be able to perform the following operations:

翻译中…
  • Replace number $*a*[1][*p*]$ by $*v*$ and rebuild the table.
  • Find the number $*a*[*x*][*y*]$, which will be the new password.
翻译中…

Doing all these steps manually is very tedious, so the jury asks you to help him. Write a program that responds to the request of the jury.

翻译中…

Input

翻译中…

The first line contains an integer $*n*$ ($1 ≤ *n* ≤ 100000$) — the number of columns. The second line contains the description of the first row of the table, that is, $*n*$ integers, which are not less than $1$ and do not exceed $10^{9}$.

翻译中…

The third line of the input contains an integer $*m*$ ($1 ≤ *m* ≤ 100000$) — the number of requests.

翻译中…

Next, each row contains a description of the request, which consists of three integers:

翻译中…
  • If the first number is equal to $1$, then the remaining two numbers are $*v*$, $*p*$ ($1 ≤ *v* ≤ 10^{9}$; $1 ≤ *p* ≤ *n*$). So, you should put value $*v*$ in the position $*p*$ in the first row.
  • If the first number is equal to $2$, then the remaining two numbers are $*x*$, $*y*$ ($1 ≤ *x* ≤ 10^{5}$; $1 ≤ *y* ≤ *n*$) — the row and column of the table cell from which you want to get value.
翻译中…

Output

翻译中…

Print an answer for each request of the second type in the order you receive them.

翻译中…

样例

Input #1
6
1 2 2 2 3 1
3
2 2 3
1 3 3
2 3 4
Output #1
2
1
InputCopy OutputCopy
题目信息
题号
418E
时间限制
3.5 s
内存限制
512 MB
标签
数据结构

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。