#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > adjList;
vector<int> p;
vector<bool> vis;
void dfs(int u, int pr) {
  vis[u] = 1;
  p[u] = pr;
  for (int i = 0; i < (int)adjList[u].size(); i++) {
    int v = adjList[u][i];
    if (!vis[v]) dfs(v, u);
  }
}
int main() {
  int n, r1, r2;
  scanf("%d%d%d", &n, &r1, &r2);
  adjList.assign(n + 1, vector<int>(0));
  p.assign(n + 1, 0);
  vis.assign(n + 1, 0);
  int x;
  for (int i = 1; i <= n; i++) {
    if (i == r1) {
      continue;
    }
    scanf("%d", &x);
    p[i] = x;
    adjList[x].push_back(i);
    adjList[i].push_back(x);
  }
  dfs(r2, -1);
  for (int i = 1; i <= n; i++) {
    if (i == r2) continue;
    printf("%d ", p[i]);
  }
}
