#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int M = 30004;
const int N = 1003;
struct Edge {
  int v, w, id;
  Edge *nxt;
} nil;
Edge *NIL = &nil;
Edge edge[2 * M];
Edge *head[N], *ecnt;
inline void AddEdge(int u, int v, int w, int id) {
  ecnt->v = v;
  ecnt->w = w;
  ecnt->id = id;
  ecnt->nxt = head[u];
  head[u] = ecnt++;
  ecnt->v = u;
  ecnt->w = w;
  ecnt->id = id;
  ecnt->nxt = head[v];
  head[v] = ecnt++;
}
void Init(int siz) {
  ecnt = &edge[0];
  for (int i = 0; i < N; i++) head[i] = NIL;
}
int n, m, s, t, Ans = 2 * INF;
int dfn[N], low[N], pre[N], pcnt;
Edge *fa[N], *ans[3], *cut, *now;
void Bfs(int s, int t) {
  fa[s] = NIL;
  pre[s] = s;
  queue<int> Q;
  Q.push(s);
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    if (u == t) return;
    for (Edge *e = head[u]; e != NIL; e = e->nxt)
      if (!pre[e->v]) {
        fa[e->v] = e;
        pre[e->v] = u;
        Q.push(e->v);
      }
  }
}
bool Dfs(int u, Edge *fre) {
  bool ret;
  if (u == t)
    ret = true;
  else
    ret = false;
  dfn[u] = low[u] = ++pcnt;
  for (Edge *e = head[u]; e != NIL; e = e->nxt) {
    if (e->id == cut->id) continue;
    if (!dfn[e->v]) {
      if (Dfs(e->v, e)) {
        if (low[e->v] > dfn[u])
          if (e->w < now->w) now = e;
        ret = true;
      }
      low[u] = min(low[u], low[e->v]);
    } else if (e->id != fre->id)
      low[u] = min(low[u], dfn[e->v]);
  }
  return ret;
}
int main() {
  NIL->w = 2 * INF;
  scanf("%d %d", &n, &m);
  scanf("%d %d", &s, &t);
  Init(n);
  for (int i = 1, u, v, w; i <= m; i++) {
    scanf("%d %d %d", &u, &v, &w);
    AddEdge(u, v, w, i);
  }
  Bfs(s, t);
  if (!pre[t]) {
    printf("0\n0\n");
    return 0;
  }
  int p = t;
  ans[3] = NIL;
  while (p != s) {
    memset(dfn, 0, sizeof(dfn));
    memset(low, 0, sizeof(low));
    pcnt = 0;
    now = NIL;
    cut = fa[p];
    if (Dfs(s, NIL)) {
      if (now != NIL && fa[p]->w + now->w < Ans)
        ans[0] = fa[p], ans[1] = now, Ans = fa[p]->w + now->w;
    } else if (fa[p]->w < Ans)
      ans[0] = fa[p], ans[1] = NIL, Ans = fa[p]->w;
    p = pre[p];
  }
  if (Ans >= 2 * INF)
    printf("-1\n");
  else {
    printf("%d\n", Ans);
    if (ans[1] == NIL)
      printf("1\n%d\n", ans[0]->id);
    else {
      if (ans[0]->id > ans[1]->id) swap(ans[0], ans[1]);
      printf("2\n%d %d\n", ans[0]->id, ans[1]->id);
    }
  }
  return 0;
}
