#include<bits/stdc++.h>
using namespace std;

const int oo = 1e9 + 7;
const int N = 1e5 + 7;

int n,m,s,t;
bool vis[N];
int par[N];
vector<int>v[N], ans;

void bfs(int s){
    queue<int>q;
    q.push(s);

    vis[s] = 1;

    while(!q.empty()){
        int u = q.front();
        q.pop();

        for(auto x : v[u]){
            if(!vis[x]){
                vis[x] = 1;
                par[x] = u;
                q.push(x);
            }
        }
    }
}

signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0);

    cin >> n >> m >> s >> t;

    for(int i=1; i <= m; i++){
        int a,b; cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }

    bfs(s);

    if(!vis[t]) cout << -1;

    else{
        int cur = t;
        while(cur != -1){
            ans.push_back(cur);
            if(cur == s) break;
            cur = par[cur];
        }

        reverse(ans.begin(), ans.end());

        cout << ans.size() << "\n";
        for(auto x : ans) cout << x << " ";
    }
}
