#include <bits/stdc++.h>   using namespace std;   const int N = 2020;   vector<tuple<int, int, int> > edges;   vector<int> g[N];   vector<int> back_edge[N];   bool global;   int num[N], low[N], low2[N], cnt, pai[N], pw[N], aux[N], prev_pai[N],       prev_pw[N], sobe[N], prev_sobe[N];   int edg_used, edg_u, edg_v, edg_w;   void dfs(int u) {     num[u] = low[u] = ++cnt;     bool flag = false;     for (auto w : g[u]) {       int x, v, p;       tie(x, v, p) = edges[w];       if (v == u) swap(v, x);       if (edg_used == w) continue;       if (!num[v]) {         pai[v] = u;         pw[v] = p;         sobe[v] = w;         dfs(v);         low[u] = min(low[u], low[v]);       } else if (flag or pai[u] != v) {         low[u] = min(low[u], num[v]);         if (!global and num[u] > num[v]) back_edge[u].push_back(w);       } else if (pai[u] == v)         flag = true;     }   }   int main(void) {     int n, m;     scanf( %d %d , &n, &m);     int s, t;     scanf( %d %d , &s, &t);     for (int i = 0; i < m; i++) {       int u, v, w;       scanf( %d %d %d , &u, &v, &w);       g[u].push_back(i);       g[v].push_back(i);       edges.emplace_back(u, v, w);     }     edg_used = -1;     dfs(s);     global = true;     int S = s;     if (!low[t]) {       printf( 0 n0 n );       return 0;     }     int ans = 0x3f3f3f3f;     int edg;     int v = t;     while (v != s) {       int u = pai[v];       if (low[v] > num[u]) {         if (pw[v] < ans) edg = sobe[v];         ans = min(ans, pw[v]);       }       v = u;     }     int dupla = INT_MAX;     int x, y;     for (int i = 1; i <= n; i++) {       if (back_edge[i].empty()) continue;       int k = 0, ans = 0x3f3f3f3f;       for (int j = 0; j < back_edge[i].size(); j++) {         int e = back_edge[i][j];         int x, v, p;         tie(x, v, p) = edges[e];         if (v == i) swap(v, x);         if (num[v] < ans) k = j;       }       vector<int> c[5];       cnt = 0;       for (int j = 1; j <= n; j++) {         c[0].push_back(num[j]);         c[1].push_back(low[j]);         c[2].push_back(pai[j]);         c[3].push_back(pw[j]);         c[4].push_back(sobe[j]);         num[j] = low[j] = 0;       }       tie(edg_u, edg_v, edg_w) = edges[back_edge[i][k]];       edg_used = back_edge[i][k];       dfs(s);       ans = 0x3f3f3f3f;       int v = t, edg;       while (v != s) {         int u = pai[v];         if (low[v] > num[u]) {           if (pw[v] < ans) edg = sobe[v];           ans = min(ans, pw[v]);         }         v = u;       }       if (ans != 0x3f3f3f3f and ans + edg_w < dupla) {         dupla = ans + edg_w;         x = back_edge[i][k];         y = edg;       }       for (int j = 1; j <= n; j++) {         num[j] = c[0][j - 1];         low[j] = c[1][j - 1];         pai[j] = c[2][j - 1];         pw[j] = c[3][j - 1];         sobe[j] = c[4][j - 1];       }     }     for (int i = 1; i <= n; i++) {       prev_pai[i] = pai[i];       prev_pw[i] = pw[i];       prev_sobe[i] = sobe[i];     }     for (int i = 1; i <= n; i++) {       if (i == s) continue;       cnt = 0;       for (int j = 1; j <= n; j++) num[j] = low[j] = 0;       tie(edg_u, edg_v, edg_w) = edges[prev_sobe[i]];       edg_used = prev_sobe[i];       dfs(s);       if (!low[t]) continue;       int ans = 0x3f3f3f3f, v = t, edg;       while (v != s) {         int u = pai[v];         if (low[v] > num[u]) {           if (pw[v] < ans) edg = sobe[v];           ans = min(ans, pw[v]);         }         v = u;       }       if (ans != 0x3f3f3f3f and ans + edg_w < dupla) {         dupla = ans + edg_w;         x = prev_sobe[i];         y = edg;       }     }     if (ans == 0x3f3f3f3f and dupla == INT_MAX) {       printf( -1 n );     } else if (ans < dupla and ans != 0x3f3f3f3f)       printf( %d n1 n%d n , ans, edg + 1);     else       printf( %d n2 n%d %d n , dupla, x + 1, y + 1);     return 0;   }   