func_code_string: #include <bits/stdc++.h>   using namespace std;   template <typename T>   inline void ckmax(T& x, T y) {     x = (y > x ? y : x);   }   template <typename T>   inline void ckmin(T& x, T y) {     x = (y < x ? y : x);   }   namespace Fread {   const int SIZE = 1 << 21;   char buf[SIZE], *S, *T;   inline char getchar() {     if (S == T) {       T = (S = buf) + fread(buf, 1, SIZE, stdin);       if (S == T) return   n ;     }     return *S++;   }   }  // namespace Fread   namespace Fwrite {   const int SIZE = 1 << 21;   char buf[SIZE], *S = buf, *T = buf + SIZE;   inline void flush() {     fwrite(buf, 1, S - buf, stdout);     S = buf;   }   inline void putchar(char c) {     *S++ = c;     if (S == T) flush();   }   struct NTR {     ~NTR() { flush(); }   } ztr;   }  // namespace Fwrite   namespace Fastio {   struct Reader {     template <typename T>     Reader& operator>>(T& x) {       char c = Fread ::getchar();       T f = 1;       while (c <  0  || c >  9 ) {         if (c ==  - ) f = -1;         c = Fread ::getchar();       }       x = 0;       while (c >=  0  && c <=  9 ) {         x = x * 10 + (c -  0 );         c = Fread ::getchar();       }       x *= f;       return *this;     }     Reader& operator>>(char& c) {       c = Fread ::getchar();       while (c ==   n  || c ==    ) c = Fread ::getchar();       return *this;     }     Reader& operator>>(char* str) {       int len = 0;       char c = Fread ::getchar();       while (c ==   n  || c ==    ) c = Fread ::getchar();       while (c !=   n  && c !=    ) {         str[len++] = c;         c = Fread ::getchar();       }       str[len] =   0 ;       return *this;     }     Reader() {}   } cin;   const char endl =   n ;   struct Writer {     template <typename T>     Writer& operator<<(T x) {       if (x == 0) {         Fwrite ::putchar( 0 );         return *this;       }       if (x < 0) {         Fwrite ::putchar( - );         x = -x;       }       static int sta[45];       int top = 0;       while (x) {         sta[++top] = x % 10;         x /= 10;       }       while (top) {         Fwrite ::putchar(sta[top] +  0 );         --top;       }       return *this;     }     Writer& operator<<(char c) {       Fwrite ::putchar(c);       return *this;     }     Writer& operator<<(char* str) {       int cur = 0;       while (str[cur]) Fwrite ::putchar(str[cur++]);       return *this;     }     Writer& operator<<(const char* str) {       int cur = 0;       while (str[cur]) Fwrite ::putchar(str[cur++]);       return *this;     }     Writer() {}   } cout;   }  // namespace Fastio   const int MAXN = 1000, MAXM = 3e4;   const int INF = 2e9 + 233;   int n, m, s, t;   struct EDGE {     int nxt, to, w, id;   } edge[MAXM * 2 + 5];   int head[MAXN + 5], tot;   inline void add_edge(int u, int v, int w, int id) {     edge[++tot].nxt = head[u];     edge[tot].to = v;     edge[tot].w = w;     edge[tot].id = id;     head[u] = tot;   }   pair<int, pair<int, int> > ans;   int dfn[MAXN + 5], ofn[MAXN + 5], cnt_dfn;   int fa[MAXN + 5], fw[MAXN + 5], fid[MAXN + 5];   int num[MAXN + 5];   long long sum[MAXN + 5], sumid[MAXN + 5];   unsigned long long sumhash[MAXN + 5];   map<unsigned long long, bool> vis;   int id[MAXN + 5], lca[MAXN + 5];   set<pair<int, int> > S[MAXN + 5];   vector<pair<int, int> > to_del[MAXN + 5];   int an[MAXN + 5][10], dep[MAXN + 5];   int get_lca(int u, int v) {     if (dep[u] < dep[v]) swap(u, v);     for (int i = 9; i >= 0; --i) {       if (dep[an[u][i]] >= dep[v]) {         u = an[u][i];       }     }     if (u == v) return u;     for (int i = 9; i >= 0; --i) {       if (an[u][i] != an[v][i]) {         u = an[u][i];         v = an[v][i];       }     }     return an[u][0];   }   int l(int id) {     int x = edge[id * 2].to;     int y = edge[id * 2 - 1].to;     if (dfn[x] < dfn[y]) swap(x, y);     return x;   }   void dfs(int u) {     dfn[u] = ++cnt_dfn;     an[u][0] = fa[u];     dep[u] = dep[fa[u]] + 1;     for (int i = 1; i <= 9; ++i) {       an[u][i] = an[an[u][i - 1]][i - 1];     }     for (int i = head[u]; i; i = edge[i].nxt) {       int v = edge[i].to;       if (edge[i].id == fid[u]) continue;       if (!dfn[v]) {         fa[v] = u;         fw[v] = edge[i].w;         fid[v] = edge[i].id;         dfs(v);         num[u] += num[v];         sum[u] += sum[v];         sumid[u] += sumid[v];         sumhash[u] += sumhash[v];         if (((int)(S[id[u]]).size()) < ((int)(S[id[v]]).size())) {           swap(id[u], id[v]);         }         for (set<pair<int, int> >::iterator it = S[id[v]].begin();              it != S[id[v]].end(); ++it) {           S[id[u]].insert(*it);         }       } else if (dfn[v] < dfn[u]) {         num[u]++;         num[v]--;         sum[u] += edge[i].w;         sum[v] -= edge[i].w;         sumid[u] += edge[i].id;         sumid[v] -= edge[i].id;         S[id[u]].insert(make_pair(dfn[u], edge[i].id));         to_del[v].push_back(make_pair(dfn[u], edge[i].id));         unsigned long long hashw =             (((unsigned long long)rand() << 30) ^ (rand() << 15) ^ rand());         while (vis[hashw]) {           hashw = (((unsigned long long)rand() << 30) ^ (rand() << 15) ^ rand());         }         vis[hashw] = 1;         sumhash[u] += hashw;         sumhash[v] -= hashw;       }     }     for (int i = 0; i < ((int)(to_del[u]).size()); ++i) {       S[id[u]].erase(to_del[u][i]);     }     assert(((int)(S[id[u]]).size()) == num[u]);     if (num[u] >= 2) {       lca[u] = get_lca(l(S[id[u]].begin()->second), l(S[id[u]].rbegin()->second));     }     ofn[u] = cnt_dfn;   }   int main() {     srand((unsigned long long)time(0) ^ (unsigned long long)(new char));     Fastio ::cin >> n >> m;     Fastio ::cin >> s >> t;     for (int i = 1; i <= m; ++i) {       int u, v, w;       Fastio ::cin >> u >> v >> w;       add_edge(u, v, w, i);       add_edge(v, u, w, i);     }     for (int i = 1; i <= n; ++i) {       id[i] = i;     }     ans = make_pair(INF, make_pair(INF, INF));     dfs(s);     if (!dfn[t]) {       Fastio ::cout << 0 << Fastio ::endl;       Fastio ::cout << 0 << Fastio ::endl;       Fastio ::cout << Fastio ::endl;       return 0;     }     for (int u = t; u != s; u = fa[u]) {       if (num[u] == 0) {         ckmin(ans, make_pair(fw[u], make_pair(fid[u], 0)));       } else if (num[u] == 1) {         ckmin(ans,               make_pair(fw[u] + (int)sum[u], make_pair(fid[u], (int)sumid[u])));         int x = l(sumid[u]);         for (int v = x; v != u; v = fa[v]) {           if (num[v] == 1) {             if (dfn[get_lca(t, x)] < dfn[v]) {               ckmin(ans, make_pair(fw[u] + fw[v], make_pair(fid[u], fid[v])));             }           }         }       } else {         int x = lca[u];         for (int v = x; v != u; v = fa[v]) {           if (num[u] == num[v] && sum[u] == sum[v] && sumid[u] == sumid[v] &&               sumhash[u] == sumhash[v]) {             if (dfn[get_lca(t, x)] < dfn[v]) {               ckmin(ans, make_pair(fw[u] + fw[v], make_pair(fid[u], fid[v])));             }           }         }       }     }     if (ans.first == INF) {       Fastio ::cout << -1 << Fastio ::endl;       return 0;     }     Fastio ::cout << ans.first << Fastio ::endl;     if (ans.second.second == 0) {       Fastio ::cout << 1 << Fastio ::endl;       Fastio ::cout << ans.second.first << Fastio ::endl;     } else {       Fastio ::cout << 2 << Fastio ::endl;       Fastio ::cout << ans.second.first <<     << ans.second.second                     << Fastio ::endl;     }     return 0;   }   