#include <bits/stdc++.h>
using namespace std;
int n, r1, r2;
vector<bool> vis;
vector<int> padre;
vector<vector<int>> graph;
void dfs(int x) {
  vis[x] = 1;
  for (int y : graph[x]) {
    if (!vis[y]) {
      padre[y] = x;
      dfs(y);
    }
  }
}
int main() {
  cin >> n >> r1 >> r2;
  graph.resize(n + 1);
  vis.resize(n + 1);
  padre.resize(n + 1);
  for (int i = 1; i <= n; i++) {
    if (i == r1) continue;
    int a;
    cin >> a;
    graph[a].push_back(i);
    graph[i].push_back(a);
  }
  dfs(r2);
  for (int i = 1; i <= n; i++) {
    if (i == r2) continue;
    cout << padre[i] << " ";
  }
}
