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