Unstable String Sort
题目描述
Authors have come up with the string consisting of lowercase Latin letters.
You are given two permutations of its indices (not necessary equal) and (both of length ). Recall that the permutation is the array of length which contains each integer from to exactly once.
For all from to the following properties hold: and . It means that if you will write down all characters of in order of permutation indices, the resulting string will be sorted in the non-decreasing order.
Your task is to restore any such string of length consisting of at least distinct lowercase Latin letters which suits the given permutations.
If there are multiple answers, you can print any of them.
输入格式
The first line of the input contains two integers and ( ) — the length of the string and the number of distinct characters required.
The second line of the input contains integers ( , all are distinct integers from to ) — the permutation .
The third line of the input contains integers ( , all are distinct integers from to ) — the permutation .
输出格式
If it is impossible to find the suitable string, print "NO" on the first line.
Otherwise print "YES" on the first line and string on the second line. It should consist of lowercase Latin letters, contain at least distinct characters and suit the given permutations.
If there are multiple answers, you can print any of them.
输入输出样例
输入样例 #1
3 2
1 2 3
1 3 2
输出样例 #1
YES
abb