Vanya and Jackets
Time limit2sMemory limit1024 MB
Assign each of n days one jacket whose temperature range covers that day's temperature, never using the same jacket on two consecutive days.
Statement
Vanya wants to change his life again and plans which jacket to wear over the next days. He owns jackets. Jacket can be worn at temperatures from to , inclusive. The forecast gives temperature for day . On day , he must wear a jacket such that . 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 and (), the number of days and the number of jackets. The second line contains integers (), the temperature on each day. Then lines follow. The -th of them contains two integers and (), the temperature range of the -th jacket.
Output
If a valid schedule exists, print Yes on the first line. On the second line, print integers , where is the index of the jacket worn on day . 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.