#include <bits/stdc++.h>
const int N = 1005, M = 30005;
int vis[N], n, m;
int dfn[N], low[N], idn, ans = 2000000001, type, ans1, ans2, x, y, z, s, t, st;
int cnt;
int head[N], ban[M << 1];
struct edge {
  int t, nxt, w;
} e[M << 1];
void add(int u, int v, int w) {
  e[++cnt].t = v;
  e[cnt].nxt = head[u];
  e[cnt].w = w;
  head[u] = cnt;
}
void tarjan(int x, int fa) {
  dfn[x] = low[x] = ++idn;
  for (int i = head[x]; i; i = e[i].nxt) {
    if ((i | 1) == (fa | 1) || ban[i]) continue;
    int u = e[i].t;
    if (!dfn[u]) {
      tarjan(u, i);
      low[x] = std::min(low[x], low[u]);
      if (dfn[x] < low[u] && dfn[t] >= dfn[u] && e[st].w + e[i].w < ans) {
        type = 2, ans = e[st].w + e[i].w;
        ans1 = st >> 1, ans2 = i >> 1;
      }
    } else
      low[x] = std::min(low[x], dfn[u]);
  }
}
bool dfs(int x) {
  vis[x] = 1;
  for (int i = head[x]; i; i = e[i].nxt) {
    int u = e[i].t;
    if (vis[u] || !dfs(u)) continue;
    ban[i] = 1, ban[i ^ 1] = 1;
    memset(dfn, 0, sizeof(dfn)), idn = 0;
    st = i;
    tarjan(s, 0);
    if (dfn[t] == 0 && e[i].w < ans) type = 1, ans = e[i].w, ans1 = i >> 1;
    ban[i] = 0, ban[i ^ 1] = 0;
    return 1;
  }
  return (x == t);
}
int main() {
  scanf("%d%d", &n, &m);
  scanf("%d%d", &s, &t);
  cnt = 1;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &x, &y, &z);
    add(x, y, z), add(y, x, z);
  }
  if (!dfs(s)) {
    puts("0\n0");
    return 0;
  }
  if (ans > 2000000000) {
    puts("-1");
    return 0;
  }
  printf("%d\n", ans);
  if (type == 1) {
    puts("1");
    printf("%d\n", ans1);
  } else {
    puts("2");
    printf("%d %d\n", ans1, ans2);
  }
}
