#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)
{
dau[source] = 1;
if (source == t)
{
solve(t);
return;
}
for (auto v : edges[source])
{
if (dau[v] == 0)
{
par[v] = source;
dfs(v);
}
}
}
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());
// 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+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgbGwgbG9uZyBsb25nCiNkZWZpbmUgZGJnKHgpIGNvdXQgPDwgI3ggPDwgIiA6ICIgPDwgeCA8PCBlbmRsCiNkZWZpbmUgcmVwKGksIGEsIGIpIGZvciAoaW50IGkgPSAoYSk7IGkgPD0gKGIpOyBpKyspCiNkZWZpbmUgbWF4bSAxMDAwMDA1CiNkZWZpbmUgbWF4biAxMDAwMDUKbGwgcGFyW21heG5dLCBkYXVbbWF4bl07CnZlY3RvcjxsbD4gZWRnZXNbbWF4bV07CnZlY3RvcjxsbD4gcmVzOwpsbCBzLCBuLCBtLCB0Owp2b2lkIHNvbHZlKGxsIGRlc3RpbmF0aW9uKQp7CiAgICAvLyBkYmcoZGVzdGluYXRpb24pOwogICAgaWYgKGRlc3RpbmF0aW9uID09IHBhcltkZXN0aW5hdGlvbl0pCiAgICB7CiAgICAgICAgcmVzLnB1c2hfYmFjayhkZXN0aW5hdGlvbik7CiAgICAgICAgcmV0dXJuOwogICAgfQogICAgcmVzLnB1c2hfYmFjayhkZXN0aW5hdGlvbik7CiAgICBkZXN0aW5hdGlvbiA9IHBhcltkZXN0aW5hdGlvbl07CiAgICBzb2x2ZShkZXN0aW5hdGlvbik7Cn0Kdm9pZCBkZnMobGwgc291cmNlKQp7CiAgICBkYXVbc291cmNlXSA9IDE7CiAgICBpZiAoc291cmNlID09IHQpCiAgICB7CiAgICAgICAgc29sdmUodCk7CiAgICAgICAgcmV0dXJuOwogICAgfQogICAgZm9yIChhdXRvIHYgOiBlZGdlc1tzb3VyY2VdKQogICAgewogICAgICAgIGlmIChkYXVbdl0gPT0gMCkKICAgICAgICB7CiAgICAgICAgICAgIHBhclt2XSA9IHNvdXJjZTsKICAgICAgICAgICAgZGZzKHYpOwogICAgICAgIH0KICAgIH0KfQoKaW50IG1haW4oKQp7CiAgICBmcmVvcGVuKCJpbnB1dC50eHQiLCAiciIsIHN0ZGluKTsKICAgIGZyZW9wZW4oIm91dHB1dC50eHQiLCAidyIsIHN0ZG91dCk7CiAgICBjaW4gPj4gbiA+PiBtID4+IHMgPj4gdDsKICAgIHMtLSwgdC0tOwogICAgZm9yIChsbCBpID0gMDsgaSA8IG07IGkrKykKICAgIHsKICAgICAgICBsbCB1LCB2OwogICAgICAgIGNpbiA+PiB1ID4+IHY7CiAgICAgICAgdS0tLCB2LS07CiAgICAgICAgZWRnZXNbdV0ucHVzaF9iYWNrKHYpOwogICAgfQogICAgZm9yIChsbCBpID0gMDsgaSA8IG47IGkrKykKICAgICAgICBzb3J0KGVkZ2VzW2ldLmJlZ2luKCksIGVkZ2VzW2ldLmVuZCgpKTsKICAgIC8vIGZvcihsbCBpPTA7aTxuO2krKyl7CiAgICAvLyAgICAgLy8gY291dDw8aSsxPDwiLS0+IjsKICAgIC8vICAgICBmb3IoYXV0byBxOiBlZGdlc1tpXSkgY291dDw8cSsxPDwiICI7CiAgICAvLyAgICAgY291dDw8J1xuJzsKICAgIC8vIH0KICAgIHBhcltzXSA9IHM7CiAgICBkZnMocyk7CiAgICAvLyBjb3V0PDwxOwogICAgcmV2ZXJzZShyZXMuYmVnaW4oKSwgcmVzLmVuZCgpKTsKICAgIGZvciAoYXV0byB2IDogcmVzKQogICAgICAgIGNvdXQgPDwgdiArIDEgPDwgIiAiOwogICAgcmV0dXJuIDA7Cn0=