#include <bits/stdc++.h>
using namespace std;
const int N = 5e4 + 5;
vector<long long> adj[N];
bool visited[N];
long long mark, c, n, prvnode[N], r1, r2;
void dfs(long long x) {
  if (visited[x]) return;
  visited[x] = 1;
  for (long long u : adj[x]) {
    if (!visited[u]) prvnode[u] = x;
    dfs(u);
  }
}
void solve() {
  cin >> n >> r1 >> r2;
  for (long long i = int(1); i <= int(n); i++) {
    if (i != r1) {
      cin >> c;
      adj[i].push_back(c);
      adj[c].push_back(i);
    }
  }
  prvnode[r2] = r2;
  dfs(r2);
  for (long long i = int(1); i <= int(n); i++) {
    if (i != r2) {
      cout << prvnode[i] << " ";
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  return 0;
}
