/ AOCode / 题库 /

Mission 1 - V : Back to Home

Mission 1 - V : Back to Home

P1022 Mission 1 - V : Back to Home

Difficulty: 650\color{brown}650

Problem Background

Radar solves the problem Cui2010 gave him, and wins. So he went back to the RAO (The Republic of AOCode). Seeing him okay is so awesome, so we decided to give Radar a surprise. But Radar don’t want the surprise and wants to give it to you, but you have to solve his problem first.

So, can you solve Radar’s problem?

Problem Statement

There’s a sequence AA with nn numbers in it. Radar will give you qq queries, and there are 33 kinds:

  • 1 x1\ x

    This means you have to push the number xx to the back of AA.

  • 22

    This lets you sort the sequence.

  • 3 a3\ a

    This makes you erase all elements of value aa in AA.

    Note that if there’s no aa’s, do nothing.

  • 44

    This makes you print the smallest element in AA, then pop it.

    Note that if there’s no element in AA right then, print 1-1.

Could you make it and get the gift?

Input

nn

A1 A2 A3 AnA_1\ A_2\ A_3\ \cdots A_n

qq

query1\text{query}_1

query2\text{query}_2

query3\text{query}_3

     \ \ \ \ \ \vdots

queryq\text{query}_q

queryi(1in)\text{query}_i(1 \le i \le n) is one of below:

  • 1 x1\ x

  • 22

  • 3 a3\ a

  • 44

Output

Output kk lines (kk is the number of the 4th4^{\rm th} kind of queries), each line contains the answer of one of the queries. (One by One)

Samples

Input 1

3
3 2 1
4
1 3
3 4
1 3
4

Output 1

Input 2

3
782 474 293
4
1 777
2
3 293
4

Output 2

474

Input 3

2
999 999
3
2
3 999
4

Output 3

-1

Constraints

  • 1n1031 \le n \le 10^3
  • 1Ai1061 \le A_i \le 10^6
  • 1q1021 \le q \le 10^2
  • For all available xx's, 1x1061 \le x \le 10^6.
  • For all available aa's, 1a1061 \le a \le 10^6.

信息

ID
1022
难度
650
分类
(无)
标签
递交数
4
已通过
1
通过率
25%
上传者