atcoder#ABC283B. [ABC283B] First Query Problem

[ABC283B] First Query Problem

Score : 200200 points

Problem Statement

You are given an integer NN and a sequence A=(A1,A2,,AN)A=(A _ 1,A _ 2,\ldots,A _ N) of length NN.

Given QQ queries, process them in the given order. Each query is of one of the following two kinds:

  • 1 k x : set the value AkA _ k to xx.
  • 2 k : print the value AkA _ k.

Constraints

  • 1N1051 \leq N \leq 10 ^ 5
  • 1Q1051 \leq Q \leq 10 ^ 5
  • 0Ai109 (1iN)0 \leq A _ i \leq 10 ^ 9\ (1\leq i\leq N)
  • 1kN1\leq k\leq N for all queries.
  • 0x1090\leq x\leq 10 ^ 9 for all queries of the first kind.
  • There is at least one query of the second kind.
  • All values in the input are integers.

Input

The input is given from Standard Input in the following format:

NN

A1A _ 1 A2A _ 2 \ldots ANA _ N

QQ

query1\operatorname{query} _ 1

query2\operatorname{query} _ 2

\vdots

queryQ\operatorname{query} _ Q

Here, queryi\operatorname{query} _ i denotes the ii-th query, given in one of the following formats:

11 kk xx

22 kk

Output

Print qq lines, where qq is the number of queries of the second kind. The jj-th (1jq)(1\leq j\leq q) line should contain the response to the jj-th such query.

3
1 3 5
7
2 2
2 3
1 3 0
2 3
1 2 8
2 2
2 1
3
5
0
8
1

Initially, A=(1,3,5)A=(1,3,5).

  • For the 11-st query, A=(1,3,5)A=(1,3,5), where A2=3A _ 2=3, so 33 should be printed.
  • For the 22-nd query, A=(1,3,5)A=(1,3,5), where A3=5A _ 3=5, so 55 should be printed.
  • The 33-rd query sets the value A3A _ 3 to 00, making A=(1,3,0)A=(1,3,0).
  • For the 44-th query, A=(1,3,0)A=(1,3,0), where A3=0A _ 3=0, so 00 should be printed.
  • The 55-th query sets the value A2A _ 2 to 88, making A=(1,8,0)A=(1,8,0).
  • For the 66-th query, A=(1,8,0)A=(1,8,0), where A2=8A _ 2=8, so 88 should be printed.
  • For the 77-th query, A=(1,8,0)A=(1,8,0), where A1=1A _ 1=1, so 11 should be printed.
5
22 2 16 7 30
10
1 4 0
1 5 0
2 2
2 3
2 4
2 5
1 4 100
1 5 100
2 3
2 4
2
16
0
0
16
100
7
478 369 466 343 541 42 165
20
2 1
1 7 729
1 6 61
1 6 838
1 3 319
1 4 317
2 4
1 1 673
1 3 176
1 5 250
1 1 468
2 6
1 7 478
1 5 595
2 6
1 6 599
1 6 505
2 3
2 5
2 1
478
317
838
838
176
595
468