#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;
}