#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream& operator<<(ostream& os, vector<T> V) {
  os << "[ ";
  for (auto v : V) os << v << " ";
  return os << "]";
}
template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
const long long Mod = 1e9 + 7;
const int N = 5e4 + 7;
vector<int> G[N];
int P[N];
void dfs(int s, int p) {
  P[s] = p;
  for (auto it : G[s])
    if (it != p) dfs(it, s);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, par, r1, r2;
  cin >> n >> r1 >> r2;
  for (int i = 1; i <= n; i++) {
    if (i == r1) continue;
    cin >> par;
    G[par].push_back(i);
    G[i].push_back(par);
  }
  dfs(r2, -1);
  for (int i = 1; i <= n; i++)
    if (i != r2) cout << P[i] << " ";
  return 0;
}
