#include <bits/stdc++.h>
using namespace std;
long long dx[] = {1, 0, -1, 0};
long long dy[] = {0, 1, 0, -1};
long long gcd(long long x, long long y) {
  if (y == 0)
    return x;
  else
    return gcd(y, x % y);
}
long long expo(long long n, long long m, long long p) {
  long long r = 1;
  n = n % p;
  while (m > 0) {
    if (m % 2) r = (r * n) % p;
    n = (n * n) % p;
    m = m / 2;
  }
  return r % p;
}
bool isPrime(long long n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (long long i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
vector<long long> adj[500000];
vector<long long> ans(500000);
bool vis[500000];
void dfs(long long s, long long p) {
  vis[s] = true;
  ans[s] = p;
  for (long long i = 0; i < adj[s].size(); i++) {
    long long x = adj[s][i];
    if (!vis[x]) {
      dfs(x, s);
    }
  }
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, r1, r2;
  cin >> n >> r1 >> r2;
  r1--, r2--;
  vector<long long> par(n, -1);
  for (long long i = 0; i < n; i++) {
    if (i == r1) continue;
    long long x;
    cin >> x;
    par[i] = x - 1;
  }
  for (long long i = 0; i < n; i++) {
    if (par[i] != -1) {
      adj[par[i]].push_back(i);
      adj[i].push_back(par[i]);
    }
  }
  dfs(r2, -1);
  for (long long i = 0; i < n; i++) {
    if (ans[i] != -1) cout << ans[i] + 1 << ' ';
  }
}
