Hide

Problem J
Scouting

/problems/scouting/file/statement/en/img-0001.jpg

One of the AI Overlords has begun its systematic takeover of the continental grid. The world is divided into $N$ autonomous domains arranged linearly from west to east and numbered $1$ through $N$. Each domain has a vulnerability index representing how susceptible it is to infiltration. All domains have an initial vulnerability index of $0$.

Your scouting units continuously report live updates from the front lines. Meanwhile, Central Command must rapidly determine which domain within a strategic corridor is most vulnerable before launching coordinated strikes against the AI Overlords.

You are tasked with building the intelligence core that processes real-time updates and answers high-priority vulnerability queries.

Input

The first line contains two integers $N$ and $Q$, the number of domains and the number of operations.

Each of the next $Q$ lines describes an operation in one of the following formats:

  • U i x
    Update the vulnerability of domain $i$ to $x$.

  • Q l r
    Determine the minimum vulnerability index among domains $l$ through $r$, inclusive.

You are given that:

  • $1 \le N, Q \le 2 \times 10^5$

  • $1 \le i \le N$

  • $1 \le l \le r \le N$

  • $1 \le x \le 10^9$

Efficient processing of all operations is required.

Output

For each query operation (Q l r), output a single line containing the minimum vulnerability index in the specified range.

Sample Input 1 Sample Output 1
5 6
Q 1 5
U 3 7
Q 1 5
U 5 2
Q 4 5
Q 3 3
0
0
0
7
Sample Input 2 Sample Output 2
1 5
Q 1 1
U 1 10
Q 1 1
U 1 0
Q 1 1
0
10
0

Please log in to submit a solution to this problem

Log in