#include #include #include #include using namespace std; using ll = long long; using ull = unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) int N; int s,t; vector st; vector> E; map G; int main(){ cin >> N; st.resize(N+2); cin >> st[N] >> st[N+1]; rep(i,N) cin >> st[i]; E.resize(N+2); rep(i,N+2) G[st[i]] = i; rep(i,N+2) rep(d,30){ int to = st[i] ^ (1< I = {N}; vector D(N+2,-1); D[N] = 0; rep(i,I.size()){ int p = I[i]; for(int e : E[p]) if(D[e] == -1){ D[e] = D[p] + 1; I.push_back(e); } } if(D[N+1] == -1) cout << "-1\n"; else cout << (D[N+1]-1) << "\n"; return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ ios::sync_with_stdio(false); cin.tie(nullptr); } } ios_do_not_sync_inst;