#d1705. Fence Painting
Fence Painting
Fence Painting
Problem Description
There are fence planks numbered from . The -th plank currently has colour , and you want to repaint the -th plank to colour .
There are painters who will work in turn. The -th painter will paint one plank with colour . You may decide which plank each painter paints, but you cannot leave a painter idle.
Determine whether all planks can be repainted to their target colours; if so, output a plan.
Input Format
Multiple test cases.
The first line contains an integer ().
For each test case, the first line contains two integers () separated by a space.
The next line contains integers ().
The next line contains integers ().
The next line contains integers ().
It is guaranteed that .
Output Format
For each test case, if the planks cannot be repainted to the target colours, output one line containing NO.
If they can, first output one line containing YES.
Then output one line with integers, indicating which plank (by number) the -th arriving painter should paint. There may be multiple valid plans; output any of them.
Sample Input
6
1 1
1
1
1
5 2
1 2 2 1 1
1 2 2 1 1
1 2
3 3
2 2 2
2 2 2
2 3 2
10 5
7 3 2 1 7 9 4 2 7 9
9 9 2 1 4 9 4 2 3 9
9 9 7 4 3
5 2
1 2 2 1 1
1 2 2 1 1
3 3
6 4
3 4 2 4 1 2
2 3 1 3 1 1
2 2 3 4
Sample Output
YES
1
YES
2 2
YES
1 1 1
YES
2 1 9 5 9
NO
NO