#include <bits/stdc++.h>
using namespace std;
const int P = 1e9 + 7, INF = ~0u >> 1;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long qpow(long long a, long long n) {
  long long r = 1 % P;
  for (a %= P; n; a = a * a % P, n >>= 1)
    if (n & 1) r = r * a % P;
  return r;
}
long long inv(long long first) {
  return first <= 1 ? 1 : inv(P % first) * (P - P / first) % P;
}
const int N = 3e4 + 10;
int n, m, S, T;
int w[N];
struct _ {
  int to, id;
} fa[N];
vector<_> g[N];
int dfn[N], low[N], isbridge[N], clk;
void tarjan(int first, int fa, int z) {
  dfn[first] = low[first] = ++clk;
  for (auto &&e : g[first])
    if (e.id != z) {
      int second = e.to, id = e.id;
      if (!dfn[second]) {
        tarjan(second, id, z);
        low[first] = min(low[first], low[second]);
        if (low[e.to] > dfn[first]) isbridge[id] = 1;
      } else if (dfn[second] < dfn[first] && id != fa) {
        low[first] = min(low[first], dfn[second]);
      }
    }
}
int vis[N], c[N];
int dfs(int first) {
  if (first == T) return 1;
  int ok = 0;
  for (auto e : g[first])
    if (!vis[e.id]) {
      vis[e.id] = 1;
      if (dfs(e.to)) return c[e.id] = ok = 1;
    }
  return ok;
}
int main() {
  scanf("%d%d%d%d", &n, &m, &S, &T);
  for (int i = 1; i <= m; ++i) {
    int u, v;
    scanf("%d%d%d", &u, &v, w + i);
    g[u].push_back({v, i}), g[v].push_back({u, i});
  }
  queue<int> q;
  fa[S].to = -1, q.push(S);
  while (q.size()) {
    int first = q.front();
    q.pop();
    for (auto &&e : g[first])
      if (!fa[e.to].to) {
        fa[e.to] = {first, e.id}, q.push(e.to);
      }
  }
  if (!fa[T].to) return puts("0\n0"), 0;
  int ans = INF;
  vector<int> vec;
  for (int first = T; first != S; first = fa[first].to) {
    int id = fa[first].id;
    memset(vis, 0, sizeof vis);
    memset(c, 0, sizeof c);
    vis[id] = 1;
    if (!dfs(S)) {
      if (ans > w[id]) {
        ans = w[id];
        vec.clear();
        vec.push_back(id);
      }
      continue;
    }
    memset(dfn, 0, sizeof dfn);
    memset(low, 0, sizeof low);
    memset(isbridge, 0, sizeof isbridge);
    clk = 0;
    tarjan(S, 0, id);
    for (int i = 1; i <= m; ++i)
      if (c[i] && isbridge[i] && ans > w[id] + w[i]) {
        ans = w[id] + w[i];
        vec.clear();
        vec.push_back(id), vec.push_back(i);
      }
  }
  if (ans == INF) return puts("-1"), 0;
  printf("%d\n%d\n", ans, int(vec.size()));
  for (int t : vec) printf("%d ", t);
  putchar(10);
}
