#include <bits/stdc++.h>
using namespace std;
int P[50004];
vector<int> A[50004];
void DFS(int u, int parent) {
  P[u] = parent;
  for (vector<int>::iterator p = A[u].begin(); p != A[u].end(); ++p)
    if (*p != parent) DFS(*p, u);
}
void solve(int n, int r1, int r2) { DFS(r2, -1); }
int main() {
  int n, r1, r2, u, i;
  scanf("%d %d %d", &n, &r1, &r2);
  for (i = 1; i <= n; ++i)
    if (i != r1) {
      scanf("%d", &u);
      A[u].push_back(i), A[i].push_back(u);
    }
  solve(n, r1, r2);
  for (i = 1; i <= n; ++i)
    if (i != r2) printf("%d ", P[i]);
  return 0;
}
