#include <bits/stdc++.h>
using namespace std;
void mohammed() {
  ios::sync_with_stdio(0);
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
}
bool vis[50005];
vector<int> adj[50005];
int arr[50005];
map<int, int> mp;
int ans = 0, res = 0, n, r1, r2;
void dfs(int node, int parent) {
  vis[node] = 1;
  mp[node] = parent;
  for (int i = 0; i < adj[node].size(); i++) {
    if (!vis[adj[node][i]]) dfs(adj[node][i], node);
  }
}
int main() {
  mohammed();
  int x, y;
  cin >> n >> r1 >> r2;
  for (int i = 1; i <= n; i++) {
    if (i == r1) continue;
    cin >> x;
    arr[i] = x;
    adj[i].push_back(arr[i]);
    adj[arr[i]].push_back(i);
  }
  dfs(r2, -1);
  for (map<int, int>::iterator it = mp.begin(); it != mp.end(); it++) {
    if (it->first != r2) {
      cout << it->second << " ";
    }
  }
  return 0;
}
