#include <bits/stdc++.h>
using namespace std;
const int N = 50005;
int n, r1, r2;
vector<int> g[N];
int p[N];
void solve(int u) {
  for (int i = (0), _b = (g[u].size()); i < (_b); ++i) {
    int v = g[u][i];
    if (p[v] == 0 && v != r2) {
      p[v] = u;
      solve(v);
    }
  }
}
int main() {
  cin >> n >> r1 >> r2;
  int x;
  for (int i = (1), _b = (n + 1); i < (_b); ++i) {
    if (i != r1) {
      cin >> x;
      g[i].push_back(x);
      g[x].push_back(i);
    }
  }
  solve(r2);
  for (int i = (1), _b = (n + 1); i < (_b); ++i) {
    if (i == r2) continue;
    cout << p[i] << " ";
  }
  cout << endl;
  return 0;
}
