import sys import bisect read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N,P,Q = map(int, readline().split()) A = [0] + list(map(int, read().split())) def next_perm(A): B = [A.pop()] while A[-1] > B[-1]: B.append(A.pop()) x = A.pop() i = bisect.bisect_left(B,x) A.append(B[i]) B[i] = x A += B return A def solve(A, P, Q): next_perm(A) if A[0]: return False p = A.index(P) q = A.index(Q) if p < q: return A # とりあえず、Qを動かす A = A[:q + 1] + sorted(A[q + 1:], reverse=True) next_perm(A) p = A.index(P) q = A.index(Q) if p < q: return A assert P > Q del A[q] A.insert(p, Q) return A A = solve(A, P, Q) if not A or A[0] != 0: print(-1) else: print(*A[1:])