#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
const int M = 3e4 + 5;
template <typename T>
void read(T &x) {
  x = 0;
  int f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + c - '0';
  x *= f;
}
int n, m, s, t;
int head[N], cnt = 1;
vector<pair<int, int> > g[N];
int route[N], len;
int X[M], Y[M], C[M];
int dfn[N], low[N], dfsxu, stk[N], top, color[N], dcc;
bool flag[M << 1], vis[N], bridge[M << 1];
int ans1 = 2e9 + 1, ans2, id1, id2;
struct Edge {
  int to, next, w;
} e[M << 1];
void add(int x, int y, int c) {
  e[++cnt] = (Edge){y, head[x], c}, head[x] = cnt;
}
bool dfs1(int u) {
  vis[u] = true;
  if (u == t) return true;
  for (int i = head[u]; ~i; i = e[i].next) {
    int v = e[i].to;
    if (vis[v]) continue;
    if (dfs1(v)) return route[++len] = i >> 1, true;
  }
  return false;
}
void dfs2(int u, int num, int nai) {
  color[u] = num;
  for (int i = head[u]; ~i; i = e[i].next) {
    int v = e[i].to;
    if ((i >> 1) == nai) continue;
    if (bridge[i]) continue;
    if (color[v]) continue;
    dfs2(v, num, nai);
  }
}
int dfs3(int u, int comes) {
  vis[u] = true;
  if (u == color[t]) return comes;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i].first;
    if (vis[v]) continue;
    int val = dfs3(v, g[u][i].second);
    if (~val)
      if (~comes && C[comes] < C[val])
        return comes;
      else
        return val;
  }
  return -1;
}
void tarjan(int u, int nai) {
  dfn[u] = low[u] = ++dfsxu;
  for (int i = head[u]; ~i; i = e[i].next) {
    int v = e[i].to;
    if ((i >> 1) == nai) continue;
    if (flag[i]) continue;
    flag[i] = flag[i ^ 1] = true;
    if (!dfn[v]) {
      tarjan(v, nai);
      low[u] = min(low[u], low[v]);
      if (dfn[u] < low[v]) bridge[i] = bridge[i ^ 1] = true;
    } else
      low[u] = min(low[u], dfn[v]);
  }
}
int main() {
  memset(head, -1, sizeof(head));
  read(n), read(m), read(s), read(t);
  for (int i = 1; i <= m; i++) {
    int x, y, c;
    read(x), read(y), read(c);
    add(x, y, c), add(y, x, c);
    X[i] = x, Y[i] = y, C[i] = c;
  }
  if (!dfs1(s)) return puts("0"), puts("0"), 0;
  for (int i = 1; i <= n; i++)
    if (!dfn[i]) tarjan(i, 0);
  for (int i = 1; i <= n; i++)
    if (!color[i]) dfs2(i, ++dcc, 0);
  for (int i = 1; i <= m; i++)
    if (color[X[i]] != color[Y[i]])
      g[color[X[i]]].push_back(make_pair(color[Y[i]], i)),
          g[color[Y[i]]].push_back(make_pair(color[X[i]], i));
  memset(vis, 0, sizeof(vis));
  int val = dfs3(color[s], -1);
  if (~val) ans1 = C[val], ans2 = 1, id1 = val;
  for (int qwq = 1; qwq <= len; qwq++) {
    int c1 = route[qwq];
    memset(dfn, 0, sizeof(dfn));
    memset(low, 0, sizeof(low));
    memset(color, 0, sizeof(color));
    memset(flag, 0, sizeof(flag));
    memset(vis, 0, sizeof(vis));
    memset(bridge, 0, sizeof(bridge));
    dfsxu = dcc = 0;
    for (int i = 1; i <= n; i++)
      if (!dfn[i]) tarjan(i, c1);
    for (int i = 1; i <= n; i++)
      if (!color[i]) dfs2(i, ++dcc, c1);
    for (int i = 1; i <= n; i++) g[i].clear();
    for (int i = 1; i <= m; i++)
      if (i != c1 && color[X[i]] != color[Y[i]])
        g[color[X[i]]].push_back(make_pair(color[Y[i]], i)),
            g[color[Y[i]]].push_back(make_pair(color[X[i]], i));
    int val = dfs3(color[s], -1);
    if (~val && C[c1] + C[val] < ans1) {
      ans1 = C[c1] + C[val];
      ans2 = 2;
      id1 = c1, id2 = val;
    }
  }
  if (ans1 > 2e9) return puts("-1");
  printf("%d\n", ans1);
  printf("%d\n", ans2);
  printf("%d ", id1);
  if (ans2 > 1) printf("%d ", id2);
  puts("");
  return 0;
}
