#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dbg(x) cout << #x << " : " << x << endl
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define maxm 1000005
#define maxn 100005
ll par[maxn], dau[maxn];
vector<ll> edges[maxm];
vector<ll> res;
ll s, n, m, t;
void solve(ll destination)
{
// dbg(destination);
if (destination == par[destination])
{
res.push_back(destination);
return;
}
res.push_back(destination);
destination = par[destination];
solve(destination);
}
void dfs(ll source)
{
stack<ll> st;
st.push(source);
while(!st.empty()){
ll p = st.top();
dau[p]=1;
if(p==t){
solve(t);
return ;
}
st.pop();
for(auto v: edges[p]){
if(dau[v]==1) continue;
par[v]=p;
st.push(v);
// break;
}
}
}
int main()
{
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
cin >> n >> m >> s >> t;
s--, t--;
for (ll i = 0; i < m; i++)
{
ll u, v;
cin >> u >> v;
u--, v--;
edges[u].push_back(v);
}
for (ll i = 0; i < n; i++)
sort(edges[i].begin(), edges[i].end(),greater<ll>());
// for(ll i=0;i<n;i++){
// cout<<i+1<<"-->";
// for(auto q: edges[i]) cout<<q+1<<" ";
// cout<<'\n';
// }
par[s] = s;
dfs(s);
// cout<<1;
reverse(res.begin(), res.end());
for (auto v : res)
cout << v + 1 << " ";
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgbGwgbG9uZyBsb25nCiNkZWZpbmUgZGJnKHgpIGNvdXQgPDwgI3ggPDwgIiA6ICIgPDwgeCA8PCBlbmRsCiNkZWZpbmUgcmVwKGksIGEsIGIpIGZvciAoaW50IGkgPSAoYSk7IGkgPD0gKGIpOyBpKyspCiNkZWZpbmUgbWF4bSAxMDAwMDA1CiNkZWZpbmUgbWF4biAxMDAwMDUKbGwgcGFyW21heG5dLCBkYXVbbWF4bl07CnZlY3RvcjxsbD4gZWRnZXNbbWF4bV07CnZlY3RvcjxsbD4gcmVzOwpsbCBzLCBuLCBtLCB0Owp2b2lkIHNvbHZlKGxsIGRlc3RpbmF0aW9uKQp7CiAgICAvLyBkYmcoZGVzdGluYXRpb24pOwogICAgaWYgKGRlc3RpbmF0aW9uID09IHBhcltkZXN0aW5hdGlvbl0pCiAgICB7CiAgICAgICAgcmVzLnB1c2hfYmFjayhkZXN0aW5hdGlvbik7CiAgICAgICAgcmV0dXJuOwogICAgfQogICAgcmVzLnB1c2hfYmFjayhkZXN0aW5hdGlvbik7CiAgICBkZXN0aW5hdGlvbiA9IHBhcltkZXN0aW5hdGlvbl07CiAgICBzb2x2ZShkZXN0aW5hdGlvbik7Cn0Kdm9pZCBkZnMobGwgc291cmNlKQp7CiAgICBzdGFjazxsbD4gc3Q7CiAgICBzdC5wdXNoKHNvdXJjZSk7CiAgICB3aGlsZSghc3QuZW1wdHkoKSl7CiAgICAgICAgbGwgcCA9IHN0LnRvcCgpOwogICAgICAgIGRhdVtwXT0xOwogICAgICAgIGlmKHA9PXQpewogICAgICAgICAgICBzb2x2ZSh0KTsKICAgICAgICAgICAgcmV0dXJuIDsKICAgICAgICB9CiAgICAgICAgc3QucG9wKCk7CiAgICAgICAgZm9yKGF1dG8gdjogZWRnZXNbcF0pewogICAgICAgICAgICBpZihkYXVbdl09PTEpIGNvbnRpbnVlOwogICAgICAgICAgICBwYXJbdl09cDsKICAgICAgICAgICAgc3QucHVzaCh2KTsKICAgICAgICAgICAgLy8gYnJlYWs7CiAgICAgICAgfQogICAgfQp9CgppbnQgbWFpbigpCnsKICAgIGZyZW9wZW4oImlucHV0LnR4dCIsICJyIiwgc3RkaW4pOwogICAgZnJlb3Blbigib3V0cHV0LnR4dCIsICJ3Iiwgc3Rkb3V0KTsKICAgIGNpbiA+PiBuID4+IG0gPj4gcyA+PiB0OwogICAgcy0tLCB0LS07CiAgICBmb3IgKGxsIGkgPSAwOyBpIDwgbTsgaSsrKQogICAgewogICAgICAgIGxsIHUsIHY7CiAgICAgICAgY2luID4+IHUgPj4gdjsKICAgICAgICB1LS0sIHYtLTsKICAgICAgICBlZGdlc1t1XS5wdXNoX2JhY2sodik7CiAgICB9CiAgICBmb3IgKGxsIGkgPSAwOyBpIDwgbjsgaSsrKQogICAgICAgIHNvcnQoZWRnZXNbaV0uYmVnaW4oKSwgZWRnZXNbaV0uZW5kKCksZ3JlYXRlcjxsbD4oKSk7CiAgICAvLyBmb3IobGwgaT0wO2k8bjtpKyspewogICAgLy8gICAgIGNvdXQ8PGkrMTw8Ii0tPiI7CiAgICAvLyAgICAgZm9yKGF1dG8gcTogZWRnZXNbaV0pIGNvdXQ8PHErMTw8IiAiOwogICAgLy8gICAgIGNvdXQ8PCdcbic7CiAgICAvLyB9CiAgICBwYXJbc10gPSBzOwogICAgZGZzKHMpOwogICAgLy8gY291dDw8MTsKICAgIHJldmVyc2UocmVzLmJlZ2luKCksIHJlcy5lbmQoKSk7CiAgICBmb3IgKGF1dG8gdiA6IHJlcykKICAgICAgICBjb3V0IDw8IHYgKyAxIDw8ICIgIjsKICAgIHJldHVybiAwOwp9