#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int N = 100 * 1000 + 100;
int n, arr[N], r1, r2;
vector<int> adj[N];
void dfs(int src, int par) {
  arr[src] = par;
  for (auto x : adj[src])
    if (x != par) {
      dfs(x, src);
    }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  cin >> n >> r1 >> r2;
  --r1;
  --r2;
  for (int i = 0; i < n; i++) {
    if (i == r1) continue;
    int x;
    cin >> x;
    --x;
    adj[x].push_back(i);
    adj[i].push_back(x);
  }
  dfs(r2, -1);
  for (int i = 0; i < n; i++) {
    if (i == r2) continue;
    cout << arr[i] + 1 << ' ';
  }
}
