#include <bits/stdc++.h>
using namespace std;
const int N = 6e4;
long long vis[N];
long long ans[N];
vector<long long> adj[N];
void dfs(long long i, long long pa) {
  if (vis[i] == 1)
    return;
  else {
    vis[i] = 1;
    ans[i] = pa;
    for (vector<long long>::iterator itr = adj[i].begin(); itr != adj[i].end();
         itr++) {
      if (vis[*itr] != 1) dfs(*itr, i);
    }
  }
}
int main() {
  long long n, r1, r2;
  cin >> n >> r1 >> r2;
  long long arr[n + 1];
  adj[0].push_back(9999);
  for (long long i = 1; i <= n; i++) {
    long long x;
    if (i == r1) {
      arr[i] = -1;
    } else {
      cin >> x;
      arr[i] = x;
      adj[i].push_back(x);
      adj[x].push_back(i);
    }
  }
  dfs(r2, -1);
  ans[r2] = -1;
  for (long long j = 1; j <= n; j++) {
    if (ans[j] != -1) cout << ans[j] << " ";
  }
}
