#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int inf = 50000000;
const int maxn = 100010;
vector<int> adj[maxn];
int ans[maxn];
void dfs(int cur, int parent) {
  int i;
  ans[cur] = parent;
  for (i = 0; i < adj[cur].size(); i++) {
    if (adj[cur][i] != parent) dfs(adj[cur][i], cur);
  }
}
int main() {
  int t, i, j, n, m, r1, r2;
  scanf("%d", &n), scanf("%d", &r1), scanf("%d", &r2);
  for (i = 1; i <= n; i++) {
    if (i == r1) continue;
    scanf("%d", &m);
    adj[m].push_back(i);
    adj[i].push_back(m);
  }
  dfs(r2, 0);
  for (i = 1; i <= n; i++) {
    if (i == r2) continue;
    printf("%d ", ans[i]);
  }
  printf("\n");
  return 0;
}
