PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#CC0000026. Số không âm nhỏ nhất còn thiếu (Mex and Update)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Số không âm nhỏ nhất còn thiếu (Mex and Update)

Mex and Update

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

You have an array AA of nn non-negative integers. Each query replaces AiA_i with xx. After each replacement, output the mex of the current array: the smallest non-negative integer absent from it. Updates persist.

Input

The first line contains n,qn,q; the next line has the nn initial array values. Each of the next qq lines contains i,xi,x (one-based index ii).

Output

Print the mex after each of the qq updates, one per line.

Subtasks

  • Subtask 1 (20 points): 1≤n,q≤201\le n,q\le 20; 0≤Ai,x≤1090\le A_i,x\le10^9; 1≤i≤n1\le i\le n.
  • Subtask 2 (30 points): 1≤n,q≤9001\le n,q\le 900; 0≤Ai,x≤1090\le A_i,x\le10^9; 1≤i≤n1\le i\le n.
  • Subtask 3 (50 points): 1≤n,q≤2000001\le n,q\le 200000; 0≤Ai,x≤1090\le A_i,x\le10^9; 1≤i≤n1\le i\le n.

Examples

Input

8 5
2 0 2 2 1 1 2 5
4 3
4 4
6 3
8 1000000000
2 1

Output

4
3
6
5
0

Explanation

The successive mex values are 4, 3, 6, 5, and 0. A very large value does not force the mex above n.