#include <bits/stdc++.h>
using namespace std;
constexpr int N = 1000;
constexpr int inf = 0x7fffffff;
struct Edge {
  int idx, v, w;
};
int n, m, s, t, u, v, w, ans;
int pre[N + 9];
list<Edge> lnk[N + 9];
list<Edge>::iterator in[N + 9], out[N + 9];
Edge brg, a, b;
int dfn[N + 9], low[N + 9], cnt;
bool f, success;
void dfs(int idx, int u) {
  for (auto it = lnk[u].begin(); it != lnk[u].end(); ++it) {
    if (it->idx == idx) out[u] = it;
    if (!pre[it->v]) {
      in[it->v] = it;
      pre[it->v] = u;
      dfs(it->idx, it->v);
    }
  }
}
void hfs(int idx, int u) {
  low[u] = dfn[u] = ++cnt;
  f |= u == t;
  int v;
  bool g;
  for (const auto &e : lnk[u])
    if (e.idx != idx) {
      v = e.v;
      if (!dfn[v]) {
        g = f;
        hfs(e.idx, v);
        low[u] = min(low[u], low[v]);
        if (!g && f && dfn[u] < low[v])
          if (brg.w > e.w) brg = e;
      } else {
        low[u] = min(low[u], dfn[v]);
      }
    }
}
int main() {
  scanf("%d%d", &n, &m);
  scanf("%d%d", &s, &t);
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d%d", &u, &v, &w);
    lnk[u].push_back((Edge){i, v, w});
    lnk[v].push_back((Edge){i, u, w});
  }
  pre[s] = -1;
  dfs(0, s);
  if (!pre[t]) {
    puts("0");
    puts("0");
    return 0;
  }
  ans = inf;
  for (int i = t; ~pre[i]; i = pre[i]) {
    Edge x = *out[i], y = *in[i];
    lnk[i].erase(out[i]);
    lnk[pre[i]].erase(in[i]);
    brg.w = inf;
    f = false;
    cnt = 0;
    memset(dfn, 0, sizeof dfn);
    memset(low, 0, sizeof low);
    hfs(0, s);
    lnk[i].push_back(x);
    lnk[pre[i]].push_back(y);
    if (f) {
      if (brg.w < inf && ans > x.w + brg.w) {
        ans = x.w + brg.w;
        a = x, b = brg;
      }
    } else {
      if (ans > x.w) {
        ans = x.w;
        a = x, b.w = 0;
      }
    }
  }
  if (ans < inf) {
    printf("%d\n", ans);
    if (b.w)
      printf("2\n%d %d\n", a.idx, b.idx);
    else
      printf("1\n%d\n", a.idx);
  } else {
    puts("-1");
  }
  return 0;
}
