#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
const double PI = 3.141592653589793;
const int N = 100000;
bool vis[N];
vector<int> graf[N];
int tab[N], i, j, k, k2, pop[N], n, r1, r2;
void dfs(int w, int o) {
  pop[w] = o;
  vis[w] = true;
  for (int i = 0; i < graf[w].size(); i++)
    if (!vis[graf[w][i]]) dfs(graf[w][i], w);
}
int main() {
  scanf("%d %d %d", &n, &r1, &r2);
  for (i = 1; i <= n; i++) {
    graf[i].resize(0);
    vis[i] = false;
  }
  i = 1;
  for (j = 0; j < n - 1; j++) {
    if (i == r1) i++;
    scanf("%d", &tab[i]);
    graf[i].push_back(tab[i]);
    graf[tab[i]].push_back(i);
    i++;
  }
  dfs(r1, -1);
  k = pop[r2];
  k2 = r2;
  while (k != -1) {
    tab[k] = k2;
    k = pop[k];
    k2 = pop[k2];
  }
  for (i = 1; i <= n; i++)
    if (i != r2) printf("%d ", tab[i]);
  printf("\n");
  return 0;
}
