#include <bits/stdc++.h>
using namespace std;
inline long long rd() {
  long long x = 0;
  int ch = getchar(), f = 1;
  while (!isdigit(ch) && (ch != '-') && (ch != EOF)) ch = getchar();
  if (ch == '-') {
    f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline void rt(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10)
    rt(x / 10), putchar(x % 10 + '0');
  else
    putchar(x + '0');
}
const int maxn = 1005, maxm = 30005;
int n, m, s, t, mn;
int ans[3];
struct tree {
  int to[maxn << 1], nx[maxm << 1], val[maxm << 1], hd[maxn], cnt,
      idx[maxm << 1];
  void clear() {
    memset(hd, -1, sizeof hd);
    cnt = 0;
  }
  void addedge(int u, int v, int w, int id) {
    to[cnt] = v;
    nx[cnt] = hd[u];
    val[cnt] = w;
    idx[cnt] = id;
    hd[u] = cnt++;
    to[cnt] = u;
    nx[cnt] = hd[v];
    val[cnt] = w;
    idx[cnt] = id;
    hd[v] = cnt++;
  }
  bool getans(int u, int gol, int fa, int ano, int valano) {
    if (u == gol) return 1;
    for (int i = hd[u]; ~i; i = nx[i]) {
      int v = to[i];
      if (v == fa) continue;
      if (getans(v, gol, u, ano, valano)) {
        if (~ano) {
          if (valano + val[i] < mn) {
            mn = valano + val[i];
            ans[0] = 2, ans[1] = ano, ans[2] = idx[i];
          }
        } else if (val[i] < mn)
          mn = val[i], ans[0] = 1, ans[1] = idx[i];
        return 1;
      }
    }
    return 0;
  }
} T;
struct graph {
  int to[maxm << 1], nx[maxm << 1], val[maxm << 1], hd[maxn], cnt,
      del[maxm << 1];
  graph() {
    memset(hd, -1, sizeof hd);
    cnt = 0;
    memset(pre, -1, sizeof pre);
  }
  void addedge(int u, int v, int w) {
    to[cnt] = v;
    nx[cnt] = hd[u];
    val[cnt] = w;
    hd[u] = cnt++;
  }
  int dfn[maxn], low[maxn], blt[maxn];
  int bc, ks, brg[maxm], tim;
  bool isbrg[maxm << 1];
  void dfs(int u, int fa) {
    dfn[u] = low[u] = ++tim;
    for (int i = hd[u]; ~i; i = nx[i]) {
      if ((i == (fa ^ 1)) || del[i]) continue;
      int v = to[i];
      if (dfn[v])
        low[u] = min(low[u], dfn[v]);
      else {
        dfs(v, i), low[u] = min(low[u], low[v]);
        if (low[v] > dfn[u]) brg[++bc] = i, isbrg[i] = isbrg[i ^ 1] = 1;
      }
    }
  }
  void getks(int u) {
    blt[u] = ks;
    for (int i = hd[u]; ~i; i = nx[i]) {
      int v = to[i];
      if (isbrg[i] || del[i]) continue;
      if (!blt[v]) getks(v);
    }
  }
  void solve(int del) {
    memset(isbrg, 0, sizeof isbrg);
    memset(dfn, 0, sizeof dfn);
    tim = 0;
    bc = 0, dfs(s, -1);
    memset(blt, 0, sizeof blt);
    ks = 0;
    for (int i = 1; i <= (int)n; i++)
      if (dfn[i] && !blt[i]) ks++, getks(i);
    if (!dfn[t] && del == -1) puts("0\n0"), exit(0);
    if (blt[s] != blt[t]) {
      T.clear();
      for (int i = 1; i <= (int)bc; i++)
        T.addedge(blt[to[brg[i]]], blt[to[brg[i] ^ 1]], val[brg[i]],
                  brg[i] / 2 + 1);
      T.getans(blt[s], blt[t], -1, del, val[del * 2 - 1]);
    }
  }
  int pre[maxn], que[maxn], head, tail;
  int nop, pat[maxn];
  void findpath(int s, int t) {
    head = 1, tail = 0, que[++tail] = s;
    pre[s] = 0;
    while (pre[t] == -1) {
      int u = que[head++];
      for (int i = hd[u]; ~i; i = nx[i]) {
        int v = to[i];
        if (pre[v] == -1) {
          pre[v] = i;
          que[++tail] = v;
        }
      }
    }
    int p = t;
    while (p != s) pat[++nop] = pre[p] / 2 + 1, p = to[pre[p] ^ 1];
  }
} G;
int main() {
  n = rd(), m = rd(), s = rd(), t = rd();
  for (int i = 1; i <= (int)m; i++) {
    int u = rd(), v = rd(), w = rd();
    G.addedge(u, v, w), G.addedge(v, u, w);
  }
  mn = 2100000000;
  G.solve(-1);
  G.findpath(s, t);
  for (int _ = 1; _ <= (int)G.nop; _++) {
    int i = G.pat[_];
    G.del[i * 2 - 2] = G.del[i * 2 - 1] = 1;
    G.solve(i);
    G.del[i * 2 - 2] = G.del[i * 2 - 1] = 0;
  };
  if (mn == 2100000000) return puts("-1"), 0;
  rt(mn), putchar('\n'), rt(*ans), putchar('\n');
  for (int i = 1; i <= (int)*ans; i++) rt(ans[i]), putchar(' ');
}
