#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
vector<long long> result;
vector<long long> used;
vector<long long> g[100000];
void dfs(long long v) {
  used[v] = 1;
  for (long long i = 0; i < g[v].size(); i++) {
    if (!used[g[v][i]]) {
      result[g[v][i]] = v;
      dfs(g[v][i]);
    }
  }
}
void solve() {
  long long n, s, v;
  cin >> n >> s >> v;
  vector<long long> ver;
  result.resize(n + 1);
  used.resize(n + 1);
  for (long long i = 1; i <= n; i++) {
    if (i != s) {
      long long v;
      cin >> v;
      g[i].push_back(v);
      g[v].push_back(i);
    }
  }
  long long p(0), t(0);
  dfs(v);
  for (long long i = 1; i <= n; i++) {
    if (i != v) cout << result[i] << " ";
  }
}
int main() {
  long long t = 1;
  while (t--) solve();
  return 0;
}
