#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
#define inf 1000000000000000000
vector<ll> edges[maxm];
ll d[maxn],par[maxn],dau[maxn];
ll n,m,s,t;
vector<ll> res;
void solve(ll destination){
if(destination==par[destination]){
res.push_back(destination);
return;
}
res.push_back(destination);
destination = par[destination];
solve(destination);
}
void bfs(ll source){
dau[source]=1;
d[source]=0;
queue<ll> q;
q.push(source);
while(!q.empty()){
ll p = q.front();
q.pop();
for(auto v: edges[p]){
if(dau[v]==1) continue;
dau[v]=1;
if(d[v]>d[p]+1){
par[v]=p;
d[v]=d[p]+1;
}
q.push(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++) d[i]=inf;
par[s]=s;
bfs(s);
solve(t);
reverse(res.begin(),res.end());
for(auto v: res) cout<<v+1<<" ";
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBsbCBsb25nIGxvbmcgCiNkZWZpbmUgZGJnKHgpIGNvdXQ8PCN4PDwiIDogIjw8eDw8ZW5kbAojZGVmaW5lIHJlcChpLGEsYikgZm9yKGludCBpPShhKTtpPD0oYik7aSsrKQojZGVmaW5lIG1heG0gMTAwMDAwNQojZGVmaW5lIG1heG4gMTAwMDA1CiNkZWZpbmUgaW5mIDEwMDAwMDAwMDAwMDAwMDAwMDAKdmVjdG9yPGxsPiBlZGdlc1ttYXhtXTsKbGwgZFttYXhuXSxwYXJbbWF4bl0sZGF1W21heG5dOwpsbCBuLG0scyx0Owp2ZWN0b3I8bGw+IHJlczsKdm9pZCBzb2x2ZShsbCBkZXN0aW5hdGlvbil7CiAgICBpZihkZXN0aW5hdGlvbj09cGFyW2Rlc3RpbmF0aW9uXSl7CiAgICAgICAgcmVzLnB1c2hfYmFjayhkZXN0aW5hdGlvbik7CiAgICAgICAgcmV0dXJuOwogICAgfQogICAgcmVzLnB1c2hfYmFjayhkZXN0aW5hdGlvbik7CiAgICBkZXN0aW5hdGlvbiA9IHBhcltkZXN0aW5hdGlvbl07CiAgICBzb2x2ZShkZXN0aW5hdGlvbik7Cn0Kdm9pZCBiZnMobGwgc291cmNlKXsKICAgIGRhdVtzb3VyY2VdPTE7CiAgICBkW3NvdXJjZV09MDsKICAgIHF1ZXVlPGxsPiBxOwogICAgcS5wdXNoKHNvdXJjZSk7CiAgICB3aGlsZSghcS5lbXB0eSgpKXsKICAgICAgICBsbCBwID0gcS5mcm9udCgpOwogICAgICAgIHEucG9wKCk7CiAgICAgICAgZm9yKGF1dG8gdjogZWRnZXNbcF0pewogICAgICAgICAgICBpZihkYXVbdl09PTEpIGNvbnRpbnVlOwogICAgICAgICAgICBkYXVbdl09MTsKICAgICAgICAgICAgaWYoZFt2XT5kW3BdKzEpewogICAgICAgICAgICAgICAgcGFyW3ZdPXA7CiAgICAgICAgICAgICAgICBkW3ZdPWRbcF0rMTsKICAgICAgICAgICAgfQogICAgICAgICAgICBxLnB1c2godik7CiAgICAgICAgfQogICAgfQp9CmludCBtYWluKCl7CiAgICAvLyBmcmVvcGVuKCJpbnB1dC50eHQiLCJyIixzdGRpbik7CiAgICAvLyBmcmVvcGVuKCJvdXRwdXQudHh0IiwidyIsc3Rkb3V0KTsKICAgIGNpbj4+bj4+bT4+cz4+dDsKICAgIHMtLSx0LS07CiAgICBmb3IobGwgaT0wO2k8bTtpKyspewogICAgICAgIGxsIHUsdjsKICAgICAgICBjaW4+PnU+PnY7CiAgICAgICAgdS0tLHYtLTsKICAgICAgICBlZGdlc1t1XS5wdXNoX2JhY2sodik7CiAgICB9CiAgICBmb3IobGwgaT0wO2k8bjtpKyspIHNvcnQoZWRnZXNbaV0uYmVnaW4oKSxlZGdlc1tpXS5lbmQoKSk7CiAgICBmb3IobGwgaT0wO2k8bjtpKyspIGRbaV09aW5mOwogICAgcGFyW3NdPXM7CiAgICBiZnMocyk7CiAgICBzb2x2ZSh0KTsKICAgIHJldmVyc2UocmVzLmJlZ2luKCkscmVzLmVuZCgpKTsKICAgIGZvcihhdXRvIHY6IHJlcykgY291dDw8disxPDwiICI7CiAgICByZXR1cm4gMDsKfQ==