#include <bits/stdc++.h>
using namespace std;
const int N = 5 * 10000 + 100;
int n, r1, r2, ans[N];
bool vis[N];
vector<int> adj[N];
void read() {
  cin >> n >> r1 >> r2;
  for (int i = 1, p; i <= n; i++) {
    if (i == r1) continue;
    cin >> p;
    adj[p].push_back(i);
    adj[i].push_back(p);
  }
}
void dfs(int root, int par = -1) {
  if (par > 0) ans[root] = par;
  vis[root] = true;
  for (auto u : adj[root])
    if (!vis[u]) dfs(u, root);
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  read();
  dfs(r2);
  for (int i = 1; i <= n; i++)
    if (ans[i]) cout << ans[i] << ' ';
  cout << endl;
  return 0;
}
