#include <bits/stdc++.h>   using namespace std;   const int MAXN = 2000;   const int MAXE = 30001;   const int INF = 2000000002;   struct edge {     int to;     int w;     int id;     edge() {}     edge(int to, int w, int id) : to(to), w(w), id(id) {}     bool operator==(const edge& e) const {       return to == e.to && w == e.w && id == e.id;     }   };   int cost[MAXE];   int conn[MAXN][MAXN];   int find_path(int s, int t, const vector<vector<edge> >& g, vector<edge>& path,                 vector<int>& used) {     used[s] = 1;     if (s == t) {       return 1;     }     for (auto& val : g[s]) {       int to = val.to;       if (!used[to]) {         path.push_back(val);         int res = find_path(to, t, g, path, used);         if (res) {           return res;         }         path.pop_back();       }     }     return 0;   }   int timer, tin[MAXN], fup[MAXN];   void dfs(int v, const vector<vector<edge> >& g, vector<int>& bridges,            vector<int>& used, int p = -1) {     used[v] = true;     tin[v] = fup[v] = timer++;     for (auto& val : g[v]) {       int to = val.to;       if (to == p) continue;       if (used[to])         fup[v] = min(fup[v], tin[to]);       else {         dfs(to, g, bridges, used, v);         fup[v] = min(fup[v], fup[to]);         if (fup[to] > tin[v] && conn[v][to] == 1) {           int id = val.id;           bridges[id] = 1;         }       }     }   }   void find_bridges(const vector<vector<edge> >& g, vector<int>& bridges) {     timer = 0;     vector<int> used(MAXN, 0);     for (int i = 1; i < g.size(); ++i)       if (!used[i]) dfs(i, g, bridges, used);   }   pair<int, int> find_best(int s, int t, const vector<vector<edge> >& g) {     vector<edge> path;     vector<int> used(MAXN, 0);     int res = find_path(s, t, g, path, used);     if (!res) {       return make_pair(0, -1);     }     vector<int> bridges(MAXE, 0);     find_bridges(g, bridges);     int min_price = INF;     int best_id = -1;     for (auto& val : path) {       int id = val.id;       if (bridges[id] && cost[id] < min_price) {         best_id = id;         min_price = cost[id];       }     }     return make_pair(min_price, best_id);   }   void remove(vector<vector<edge> >& g, int cur, edge val) {     int to = val.to;     auto it = find(g[cur].begin(), g[cur].end(), val);     g[cur].erase(it);     val.to = cur;     it = find(g[to].begin(), g[to].end(), val);     g[to].erase(it);     conn[cur][to]--;     conn[to][cur]--;   }   void restore(vector<vector<edge> >& g, int cur, edge val) {     int to = val.to;     g[cur].push_back(val);     val.to = cur;     g[to].push_back(val);     conn[cur][to]++;     conn[to][cur]++;   }   int main(int argc, char const* argv[]) {     vector<vector<edge> > g(MAXN);     int n, m;     cin >> n >> m;     int s, t;     cin >> s >> t;     for (int i = 0; i < m; i++) {       int x, y, w;       cin >> x >> y >> w;       g[x].push_back(edge(y, w, i));       g[y].push_back(edge(x, w, i));       conn[x][y]++;       conn[y][x]++;       cost[i] = w;     }     vector<edge> path;     vector<int> used(MAXN, 0);     int res = find_path(s, t, g, path, used);     if (!res) {       cout << 0 <<   n ;       cout << 0;       return 0;     }     int best_price = INF;     int cur = s;     int id1, id2;     for (auto val : path) {       int id = val.id;       int to = val.to;       remove(g, cur, val);       pair<int, int> best = find_best(s, t, g);       if (best.first < INF) {         int cur_price = val.w + best.first;         if (cur_price < best_price) {           id1 = val.id;           id2 = best.second;           best_price = cur_price;         }       }       restore(g, cur, val);       cur = to;     }     if (best_price >= INF) {       cout << -1;       return 0;     }     cout << best_price <<   n ;     if (id2 == -1) {       cout << 1 <<   n ;       cout << id1 + 1;     } else {       cout << 2 <<   n ;       cout << id1 + 1 <<     << id2 + 1 <<   n ;     }     return 0;   }