#include <bits/stdc++.h>
using namespace std;
const long long maxn = 3e5 + 10, N = 1001, LOG = 25, mod = 1e9 + 7,
                inf = 1e9 + 7;
long long n, r1, r2, par[maxn];
vector<int> adj[maxn];
void dfs(int u, int v = -1) {
  par[u] = v;
  for (int i : adj[u])
    if (i != v) dfs(i, u);
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  cin >> n >> r1 >> r2;
  for (int i = 0; i < n; i++) {
    if (i + 1 == r1) continue;
    int a;
    cin >> a;
    adj[a].push_back(i + 1);
    adj[i + 1].push_back(a);
  }
  dfs(r2);
  for (int i = 1; i <= n; i++)
    if (i != r2) cout << par[i] << " ";
  cout << endl;
  return 0;
}
