#include <bits/stdc++.h>
using namespace std;
const int N = 5 * 1e4 + 10;
int p[N];
int n, m, k;
vector<int> A[N];
bool color[N];
void DFS(int u) {
  color[u] = 1;
  for (int i = 0; i < A[u].size(); i++) {
    int v = A[u][i];
    if (!color[v]) {
      p[v] = u;
      DFS(v);
    }
  }
}
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) {
    if (i != m) {
      int x;
      cin >> x;
      A[i].push_back(x);
      A[x].push_back(i);
    }
  }
  DFS(k);
  for (int i = 1; i <= n; i++) {
    if (i != k) {
      cout << p[i] << " ";
    }
  }
}
