#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 10;
const int maxm = 30000 + 10;
struct Edge {
  int next, v, w, id;
  Edge() {}
  Edge(int next, int v, int w, int id) : next(next), v(v), w(w), id(id) {}
} e[maxm << 1];
struct Line {
  int u, v, w;
  Line() {}
  Line(int u, int v, int w) : u(u), v(v), w(w) {}
  bool operator==(const Line& tmp) const {
    return u == tmp.u && v == tmp.v && w == tmp.w;
  }
} L[maxm];
int n, m;
int S, T;
int ans = 2e9 + 10, c1, c2, tot;
int path[maxm], dep[maxn];
int head[maxn], cnt;
int bcc[maxn], totbcc;
int dfn[maxn], low[maxn], timer;
int st[maxm], top;
bool vis[maxm], bridge[maxm], used[maxn];
int g[maxn][maxn];
vector<int> G[maxn];
inline int read() {
  int x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x;
}
inline void AddEdge(int u, int v, int w, int id) {
  e[++cnt] = Edge(head[u], v, w, id);
  head[u] = cnt;
  e[++cnt] = Edge(head[v], u, w, id);
  head[v] = cnt;
}
bool dfs_path(int u, int pre = 0) {
  used[u] = 1;
  if (T == u) return true;
  for (int i = head[u]; i; i = e[i].next) {
    int v = e[i].v;
    if (!used[v]) {
      path[dep[u]] = e[i].id;
      dep[v] = dep[u] + 1;
      if (dfs_path(v, u)) return true;
    }
  }
  return false;
}
void dfs(int u, int pre = 0) {
  bool flag = 0;
  dfn[u] = low[u] = ++timer;
  for (int i = head[u]; i; i = e[i].next) {
    if (vis[e[i].id]) continue;
    int v = e[i].v;
    if (v == pre && !flag) {
      flag = 1;
      continue;
    }
    if (!dfn[v]) {
      dfs(v, u);
      low[u] = min(low[u], low[v]);
      if (low[v] > dfn[u]) bridge[e[i].id] = 1;
    } else if (dfn[v] < dfn[u])
      low[u] = min(low[u], dfn[v]);
  }
}
void Tarjan(int u, int pre = 0) {
  bcc[u] = totbcc;
  for (int i = head[u]; i; i = e[i].next) {
    if (vis[e[i].id] || bridge[e[i].id]) continue;
    int v = e[i].v;
    if (!bcc[v]) Tarjan(v, u);
  }
}
inline void Find_bcc() {
  memset(bridge, 0, sizeof(bridge));
  memset(bcc, 0, sizeof(bcc));
  memset(dfn, 0, sizeof(dfn));
  memset(low, 0, sizeof(low));
  timer = totbcc = 0;
  for (int i = 1; i <= n; i++)
    if (!dfn[i]) dfs(i);
  for (int i = 1; i <= n; i++)
    if (!bcc[i]) {
      totbcc++;
      Tarjan(i);
    }
}
bool dfs_bridge(int u, int d = 1) {
  used[u] = 1;
  if (u == bcc[T]) {
    top = d - 1;
    return true;
  }
  for (int i = 0, _ = (int)G[u].size(); i < _; i++) {
    int v = G[u][i];
    if (!used[v]) {
      st[d] = g[u][v];
      if (dfs_bridge(v, d + 1)) return true;
    }
  }
  return false;
}
int main() {
  if (fopen("700C.in", "r") != NULL) {
    freopen("700C.in", "r", stdin);
    freopen("700C.out", "w", stdout);
  }
  n = read(), m = read();
  S = read(), T = read();
  for (int i = 1, u, v, w; i <= m; i++) {
    u = read(), v = read(), w = read();
    L[i] = Line(u, v, w);
    AddEdge(u, v, w, i);
  }
  dep[S] = 1;
  if (!dfs_path(S)) {
    puts("0\n0");
    return 0;
  }
  for (int p = 1, _ = dep[T]; p < _; p++) {
    vis[path[p]] = 1;
    Find_bcc();
    if (bcc[S] == bcc[T]) {
      vis[path[p]] = 0;
      continue;
    }
    for (int i = 1; i <= n; i++) G[i].clear(), used[i] = 0;
    int res = 2e9, cur;
    for (int u = 1; u <= n; u++)
      for (int i = head[u]; i; i = e[i].next) {
        if (vis[e[i].id] || !bridge[e[i].id]) continue;
        int v = e[i].v;
        if (bcc[u] != bcc[v]) {
          G[bcc[u]].push_back(bcc[v]);
          g[bcc[u]][bcc[v]] = e[i].id;
        }
      }
    if (dfs_bridge(bcc[S]))
      for (int i = 1; i <= top; i++)
        if (L[st[i]].w < res) res = L[st[i]].w, cur = st[i];
    if (res == 2e9) res = 0;
    if (L[path[p]].w + res < ans) {
      ans = L[path[p]].w + res;
      if (res == 0) {
        tot = 1;
        c1 = path[p], c2 = 0;
      } else {
        tot = 2;
        c1 = path[p], c2 = cur;
      }
    }
    vis[path[p]] = 0;
  }
  if (!tot)
    puts("-1");
  else {
    printf("%d\n%d\n", ans, tot);
    printf("%d", c1);
    if (tot > 1) printf(" %d", c2);
    puts("");
  }
  return 0;
}
