Under construction

Still being built. Things may change

Vanya and Jackets

Time limit2sMemory limit1024 MB

Summary
Assign each of n days one jacket whose temperature range covers that day's temperature, never using the same jacket on two consecutive days.
Level

Medium7 of 10

Topics
Greedy, Sorting, Heap
Solved
No attempts yet

Statement

Vanya wants to change his life again and plans which jacket to wear over the next nn days. He owns mm jackets. Jacket ii can be worn at temperatures from lil_i to rir_i, inclusive. The forecast gives temperature aja_j for day jj. On day jj, he must wear a jacket ii such that li≤aj≤ril_i \le a_j \le r_i. He never wears the same jacket on two consecutive days. His mother does not allow him to leave home without a jacket or to wear more than one, so every day needs exactly one jacket. Build a schedule that satisfies all of these rules.

Input

The first line contains two integers nn and mm (1≤n,m≤1000001 \le n, m \le 100000), the number of days and the number of jackets. The second line contains nn integers a1,a2,...,ana_1, a_2, ..., a_n (0≤ai≤1090 \le a_i \le 10^9), the temperature on each day. Then mm lines follow. The ii-th of them contains two integers lil_i and rir_i (0≤li≤ri≤1090 \le l_i \le r_i \le 10^9), the temperature range of the ii-th jacket.

Output

If a valid schedule exists, print Yes on the first line. On the second line, print nn integers b1,b2,...,bnb_1, b_2, ..., b_n, where bib_i is the index of the jacket worn on day ii. Jackets are numbered from 1 in input order. Otherwise, print No. If several schedules are valid, print any of them.

Hint

In the first sample, the answer 2 1 2 4 is not the only correct one. Another correct answer is 1 2 1 4. In the second sample, no valid schedule exists because the first jacket is the only option for both day 1 and day 2.

Examples2

  1. Example 1

    Input
    4 4
    25 25 30 50
    10 40
    20 30
    70 100
    50 50
    
    Expected output
    Yes
    2 1 2 4
    
  2. Example 2

    Input
    4 2
    30 40 50 60
    30 40
    50 60
    
    Expected output
    No