#include <bits/stdc++.h>
using namespace std;
const int N = 5e4 + 1;
vector<int> adj[N], neww(N);
bool vis[N] = {};
void dfs(int r1) {
  vis[r1] = true;
  neww[r1] = -1;
  for (int i = 0; i < adj[r1].size(); i++) {
    if (!vis[adj[r1][i]]) {
      dfs(adj[r1][i]);
      neww[adj[r1][i]] = r1 + 1;
    }
  }
}
int main() {
  int n, r1, r2;
  cin >> n >> r1 >> r2;
  for (int i = 0; i < n; i++) {
    if (i == r1 - 1) continue;
    int p;
    cin >> p;
    adj[i].push_back(p - 1);
    adj[p - 1].push_back(i);
  }
  dfs(r2 - 1);
  for (int i = 0; i < n; i++)
    if (neww[i] != -1) cout << neww[i] << " ";
  cout << endl;
  return 0;
}
