#include <bits/stdc++.h>
const int mod = 1e9 + 7;
const int MOD = 998244353;
inline int add(int x, int y) {
  x += y;
  if (x >= mod) x -= mod;
  return x;
}
inline int sub(int x, int y) {
  x -= y;
  if (x < 0) x += mod;
  return x;
}
inline int mul(int x, int y) { return (x * 1ll * y) % mod; }
using namespace std;
const long long int maxn = 5 * 1e4 + 50;
const long long int inf = 1e9;
const double pi = acos(-1);
long long int n, m, a, b, c, d, p, q, x, y, z, minn, maxx;
bool vis[maxn];
long long int par[maxn];
vector<long long int> G[maxn];
void dfs(long long int node, long long int parent) {
  vis[node] = true;
  par[node] = parent;
  for (auto ch : G[node]) {
    if (!vis[ch]) {
      par[ch] = node;
      dfs(ch, node);
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  cin >> n >> a >> b;
  for (long long int i = 1; i <= n; i++) {
    if (i != a) {
      cin >> p;
      G[i].push_back(p);
      G[p].push_back(i);
    }
  }
  dfs(b, 0);
  for (long long int i = 1; i <= n; i++) {
    if (i == b) continue;
    cout << par[i] << " ";
  }
  return 0;
}
