main :-
	read_num(N),
	read_n_num_list(N, A),
        read_n_num_list(N, B),
	satisfy(A, B),
        halt.
main :-
        write('No'), nl,
        halt.
        

satisfy(A, B) :-
        permutation(B, PB),
        test_elements(A, PB),
        write('Yes'), nl,
        write_list(PB).
        

write_list([]) :- nl.
write_list([H|T]) :-
        write(H), write(' '),
        write_list(T).

test_elements([], []).
test_elements([HA|TA], [HB|TB]) :-
        HA =\= HB,
        test_elements(TA, TB).

read_n_num_list(Num, List) :-
	read_n_num_list_aux(Num, [], List),
	!.
read_n_num_list_aux(0, List, List).
read_n_num_list_aux(Num, Old, Accum) :-
	read_num(NewItem),
	NewNum is Num - 1,
	append(Old, [NewItem], NewList),
	read_n_num_list_aux(NewNum, NewList, Accum).

read_str(S) :-
        read_string(current_input, ' \n', '', _, S).
 
read_num(N) :-
	read_str(S),
	number_string(N, S).

