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 if max(A[q:]) == Q: second = max(A[q + 1:]) q -= 1 while A[q] > second: q -= 1 # とりあえず、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 if P > Q: del A[q] A.insert(p, Q) return A return solve(A, P, Q) A = solve(A, P, Q) if not A or A[0] != 0: print(-1) else: print(*A[1:])