#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5 * 1e4 + 7;
vector<int> graph[MAXN];
int used[MAXN];
void dfs(int v) {
  for (int i = 0; i < graph[v].size(); i++) {
    int to = graph[v][i];
    if (used[to] == -1) {
      used[to] = v;
      dfs(to);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  std::ios::sync_with_stdio(false);
  int n, r1, r2;
  cin >> n >> r1 >> r2;
  r1--;
  r2--;
  for (int i = 0; i < n; i++) {
    if (i == r1) {
      continue;
    }
    int a;
    cin >> a;
    a--;
    graph[a].push_back(i);
    graph[i].push_back(a);
  }
  for (int i = 0; i < MAXN; i++) {
    used[i] = -1;
  }
  used[r2] = -2;
  dfs(r2);
  for (int i = 0; i < n; i++) {
    if (i == r2) continue;
    cout << used[i] + 1 << " ";
  }
  return 0;
}
