Set

You have qq queries and an empty set. Each query is of the form:

  • ADD x: Add x to the set
  • ERASE x: Erase x from the set
  • NTH n: Output the n-th smallest number in the set (1-indexed)
  • MIN: Output the minimum value in the set
  • MAX: Output the maximum value in the set

Constraints

1≤q≤1051 \le q \le 10^5

1≤x≤1091 \le x \le 10^9

Common sense constraints should hold (n≤∣set∣n \le \left|\text{set}\right|).

Example 1

Input
Input 1
5
ADD 1
ADD 2
NTH 2
MIN
MAX
Input
Input 2
2
1
2

Comments0


No comments yet

Be the first to comment.

New comment


Log in to join the discussion.