#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:26000000000")
using namespace std;
const double EPS = 1e-9;
const double pi = acos(-1.0);
const int INF = (int)(1e9 + 7.5);
const int MAXN = 50005;
inline int max(int a, int b) { return a > b ? a : b; }
inline int min(int a, int b) { return a < b ? a : b; }
vector<int> g[MAXN];
vector<char> used;
int n, r1, r2, z, ans[MAXN];
void dfs(int v, int parent = -1) {
  used[v] = true;
  if (parent != -1) ans[v] = parent;
  for (size_t i = 0; i < g[v].size(); ++i) {
    int to = g[v][i];
    if (!used[to]) dfs(to, v);
  }
}
int main() {
  scanf("%d%d%d", &n, &r1, &r2);
  used.assign(n + 1, false);
  for (int i = 0; i < n; ++i) {
    if (i + 1 == r1) continue;
    scanf("%d", &z);
    g[i + 1].push_back(z);
    g[z].push_back(i + 1);
  }
  dfs(r2);
  for (int i = 0; i < MAXN; ++i)
    if (ans[i]) printf("%d ", ans[i]);
  return 0;
}
