#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)1e6;
const int inf = (int)1e9;
const int mod = (int)1e9 + 7;
const double eps = 1e-9;
int n, r1, r2, p[maxn], used[maxn], ans[maxn];
vector<int> g[maxn];
void dfs(int v, int par) {
  int to;
  ans[v] = par;
  for (int i = 0; i < (int)g[v].size(); ++i) {
    to = g[v][i];
    if (to == par) continue;
    dfs(to, v);
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> r1 >> r2;
  int ok = 0;
  for (int i = 1; i <= n; ++i) {
    if (i == r1) continue;
    cin >> p[i];
    g[i].push_back(p[i]);
    g[p[i]].push_back(i);
  }
  dfs(r2, -1);
  for (int i = 1; i <= n; ++i) {
    if (i == r2) continue;
    cout << ans[i] << ' ';
  }
  return 0;
}
