#include <bits/stdc++.h>
using namespace std;
int n, r1, r2, s;
bool vis[50009];
int parent[50009];
vector<int> arr[50009];
void dfs(int i) {
  vis[i] = true;
  for (int j = 0; j < arr[i].size(); j++) {
    if (!vis[arr[i][j]]) {
      parent[arr[i][j]] = i;
      dfs(arr[i][j]);
    }
  }
  return;
}
int main() {
  cin >> n >> r1 >> r2;
  for (int i = 1; i <= n; i++) {
    if (i == r1) continue;
    cin >> s;
    arr[i].push_back(s);
    arr[s].push_back(i);
  }
  dfs(r2);
  for (int i = 1; i <= n; i++) {
    if (i == r2) continue;
    cout << parent[i] << ' ';
  }
  return 0;
}
