#include <bits/stdc++.h>
using namespace std;
const double PI =
    3.14159265358979323846264338327950288419716939937510582097494459230;
const long long MOD = 1e9 + 7;
const long long INF = 1e14;
template <class T>
bool uin(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool uax(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
long long mpow(long long a, long long b, long long p = MOD) {
  a = a % p;
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % p;
    a = (a * a) % p;
    b = b >> 1;
  }
  return res % p;
}
const long long N = 50005;
vector<long long> a[N];
long long ans[N];
void dfs(long long node, long long p = -1) {
  ans[node] = p;
  for (auto x : a[node]) {
    if (x != p) dfs(x, node);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, r1, r2;
  cin >> n >> r1 >> r2;
  for (int i = 1; i <= (int)(n); ++i) {
    if (i == r1) continue;
    long long x;
    cin >> x;
    a[i].push_back(x);
    a[x].push_back(i);
  }
  dfs(r2);
  for (int i = 1; i <= (int)(n); ++i) {
    if (i == r2) continue;
    cout << ans[i] << " ";
  }
}
