#include <bits/stdc++.h>
using namespace std;
vector<int> adj[1000010];
int par[1000010];
void saiki(int v, int p) {
  par[v] = p;
  for (int i = 0; i < (int)(adj[v].size()); i++) {
    if (adj[v][i] == p) continue;
    saiki(adj[v][i], v);
  }
}
int main() {
  int N, R1, R2;
  while (3 == scanf("%d%d%d", &N, &R1, &R2)) {
    --R1;
    --R2;
    for (int i = 0; i < (int)(N); i++) adj[i].clear();
    for (int i = 0; i < (int)(N); i++)
      if (i != R1) {
        int p;
        scanf("%d", &p);
        --p;
        adj[i].push_back(p);
        adj[p].push_back(i);
      }
    saiki(R2, -1);
    bool first = true;
    for (int i = 0; i < (int)(N); i++)
      if (i != R2) {
        if (first)
          first = false;
        else
          putchar(' ');
        printf("%d", par[i] + 1);
      }
    puts("");
  }
  return 0;
}
