#CCBCHBAHAI0000074. Chèn x sau lần xuất hiện đầu tiên của y (Insert x After the First Occurrence of y)

Chèn x sau lần xuất hiện đầu tiên của y (Insert x After the First Occurrence of y)

Insert x After the First Occurrence of y (Chèn x sau lần xuất hiện đầu tiên của y)

Source: Phước Hưng OJ

Version: Phuoc Hung OJ Extended

Problem

A static array has capacity CC and current logical size nn, where 1≤n≤C1\le n\le C. The active sequence is a0,…,an−1a_0,\ldots,a_{n-1}. Given integers xx and yy, define

I={i∣0≤i<n, ai=y}.I=\{i\mid0\le i<n,\ a_i=y\}.

If II is empty, leave the array unchanged. If II is nonempty but n=Cn=C, the array is full, so leave it unchanged. Otherwise let p=min⁡Ip=\min I and insert xx immediately after position pp. The new size is n+1n+1, with

$$b_i=a_i\ (0\le i\le p),\qquad b_{p+1}=x,\qquad b_i=a_{i-1}\ (p+2\le i\le n).$$

Print the final logical size and array.

Input

The first line contains CC and nn. The second line contains nn integers aia_i. The third line contains xx and yy.

Output

Print the final logical size on the first line and the active array elements on the second line.

Subtask

Subtask 1 (20 points): 1≤n≤C≤101\le n\le C\le10, ∣ai∣,∣x∣,∣y∣≤103|a_i|,|x|,|y|\le10^3.

Subtask 2 (30 points): 1≤n≤C≤50001\le n\le C\le5000, ∣ai∣,∣x∣,∣y∣≤106|a_i|,|x|,|y|\le10^6.

Subtask 3 (50 points): 1≤n≤C≤2⋅1051\le n\le C\le2\cdot10^5, ∣ai∣,∣x∣,∣y∣≤109|a_i|,|x|,|y|\le10^9.

Example

Input

8 6
4 2 7 2 9 5
100 2

Output

7
4 2 100 7 2 9 5

Explanation

The sample follows the mathematical definition above.