#include <bits/stdc++.h>
using namespace std;
typedef int STDD[1010];
struct lst {
  int po;
  int num;
  lst* nxt;
};
lst* hd[1001];
int n, m, sx, sy, ans = 2E9 + 1, a1, a2;
STDD seq, tseq, fa, clr, far;
int x[30010], y[30010], z[30010];
bool vis[1001];
int getfa(int x) { return (fa[x] != x) ? (fa[x] = getfa(fa[x])) : (x); }
bool dfs(int x, int fb) {
  vis[x] = 1;
  if (x == sy) return 1;
  for (lst* p = hd[x]; p; p = p->nxt)
    if (!vis[p->po] && p->num != fb) {
      seq[++seq[0]] = p->num;
      if (!dfs(p->po, fb))
        --seq[0];
      else
        return 1;
    }
  return 0;
}
int main() {
  scanf("%d%d%d%d", &n, &m, &sx, &sy);
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d%d", x + i, y + i, z + i);
    hd[x[i]] = new lst{y[i], i, hd[x[i]]};
    ;
    hd[y[i]] = new lst{x[i], i, hd[y[i]]};
    ;
  }
  if (!dfs(sx, 0)) {
    printf("0\n0\n");
    return 0;
  }
  for (int i = 0; i <= seq[0]; ++i) tseq[i] = seq[i];
  for (int i = 1; i <= tseq[0]; ++i) {
    memset(vis, 0, sizeof(vis));
    seq[0] = 0;
    if (!dfs(sx, tseq[i]) && ans > z[tseq[i]]) {
      ans = z[tseq[i]];
      a1 = tseq[i];
      a2 = 0;
      continue;
    }
    memset(clr, 0, sizeof(clr));
    for (int j = 1; j <= n; ++j) far[j] = fa[j] = j;
    for (int j = 1; j <= seq[0]; ++j) z[seq[j]] *= -1;
    z[tseq[i]] *= -1;
    for (int j = 1; j <= m; ++j)
      if (z[j] > 0) fa[getfa(x[j])] = getfa(y[j]);
    for (int j = 1; j <= seq[0]; ++j) z[seq[j]] *= -1;
    z[tseq[i]] *= -1;
    int cr = clr[sx] = 1;
    for (int j = 1; j <= seq[0]; ++j)
      clr[(!clr[x[seq[j]]]) ? (x[seq[j]]) : (y[seq[j]])] = ++cr;
    for (int j = 1; j <= n; ++j)
      if (clr[far[getfa(j)]] < clr[j]) far[getfa(j)] = j;
    int now = far[getfa(sx)];
    for (int j = 1; j <= seq[0]; ++j) {
      if (clr[x[seq[j]]] > clr[y[seq[j]]]) swap(x[seq[j]], y[seq[j]]);
      if (clr[now] >= clr[y[seq[j]]]) {
        if (clr[far[getfa(y[seq[j]])]] > clr[now]) now = far[getfa(y[seq[j]])];
        continue;
      }
      if (z[tseq[i]] + z[seq[j]] < ans) {
        ans = z[tseq[i]] + z[seq[j]];
        a1 = tseq[i];
        a2 = seq[j];
      }
      now = far[getfa(y[seq[j]])];
    }
  }
  if (!a1)
    printf("-1\n");
  else if (!a2)
    printf("%d\n1\n%d\n", ans, a1);
  else
    printf("%d\n2\n%d %d\n", ans, a1, a2);
}
