#include <bits/stdc++.h>
using namespace std;
const int N = 5e4 + 10;
int n, r1, r2, pre[N], vis[N];
vector<int> v[N];
void dfs(int x) {
  vis[x] = 1;
  for (int i = 0; i < v[x].size(); i++) {
    int y = v[x][i];
    if (vis[y]) continue;
    pre[y] = x;
    dfs(y);
  }
}
int main() {
  scanf("%d%d%d", &n, &r1, &r2);
  for (int i = 1; i <= n; i++) {
    if (i != r1) {
      int x;
      scanf("%d", &x);
      v[x].push_back(i);
      v[i].push_back(x);
    }
  }
  dfs(r2);
  for (int i = 1; i <= n; i++)
    if (i != r2) printf("%d ", pre[i]);
  return 0;
}
