#include <bits/stdc++.h>
using namespace std;
inline int in() {
  int32_t x;
  scanf("%d", &x);
  return x;
}
inline string get() {
  char ch[1000010];
  scanf("%s", ch);
  return ch;
}
const int MAX_LG = 60;
const long long maxn = 1e6 + 100;
const long long base = 29;
const long long mod = 1e9 + 7;
const long long INF = 1e18 + 100;
vector<pair<long long, long long> > g[maxn];
bool mark[maxn];
long long pre[maxn];
long long c[maxn], v[maxn], u[maxn];
long long res = INF;
pair<long long, long long> edges;
pair<long long, long long> fedges;
long long forb;
inline void dfs(long long node, long long preId = -1) {
  mark[node] = true;
  pre[node] = preId;
  for (auto u : g[node]) {
    if (mark[u.first]) continue;
    dfs(u.first, u.second);
  }
}
inline void dfs4(long long node) {
  mark[node] = true;
  for (auto u : g[node]) {
    if (u.second == forb) continue;
    if (mark[u.first]) continue;
    dfs4(u.first);
  }
}
long long cur = 0;
long long l[maxn], h[maxn];
long long cut[maxn];
inline void dfs2(long long node, long long preId = -1) {
  h[node] = l[node] = cur++;
  mark[node] = true;
  for (auto u : g[node]) {
    if (u.second == preId || u.second == forb) continue;
    if (mark[u.first]) {
      l[node] = min(l[node], h[u.first]);
      if (l[u.first] > h[node]) cut[u.second] = true;
    } else {
      dfs2(u.first, u.second);
      l[node] = min(l[node], l[u.first]);
      if (l[u.first] > h[node]) {
        cut[u.second] = true;
      }
    }
  }
}
bool mark2[maxn][2];
long long di[maxn][2];
inline void bfs(long long node, long long fl = 0, long long h = 0) {
  mark2[node][fl] = true;
  di[node][fl] = 0;
  queue<long long> q;
  q.push(node);
  while (q.empty() == false) {
    long long v = q.front();
    q.pop();
    for (auto u : g[v]) {
      if (mark2[u.first][fl]) continue;
      if (u.second == forb) continue;
      mark2[u.first][fl] = true;
      di[u.first][fl] = di[v][fl] + 1;
      q.push(u.first);
    }
  }
}
inline bool check(long long s, long long t, long long v, long long u) {
  if (di[v][0] == di[u][0] + 1 && di[u][1] == di[v][1] + 1) return 1;
  return 0;
}
int32_t main() {
  long long n = in(), m = in();
  long long s = in(), t = in();
  for (long long i = 0; i < m; i++) {
    v[i] = in(), u[i] = in(), c[i] = in();
    g[v[i]].push_back({u[i], i});
    g[u[i]].push_back({v[i], i});
  }
  dfs(s);
  if (!mark[t]) {
    return cout << 0 << "\n" << 0 << "\n", 0;
  }
  long long node = t;
  while (node != s) {
    long long edgeId = pre[node];
    long long node2;
    if (v[edgeId] == node)
      node2 = u[edgeId];
    else
      node2 = v[edgeId];
    long long cost = c[edgeId];
    edges.first = edgeId;
    edges.second = -1;
    forb = edgeId;
    for (long long i = 0; i <= n; i++)
      mark[i] = mark2[i][0] = mark2[i][1] = false;
    dfs4(s);
    if (!mark[t]) {
      if (res > cost) res = cost, fedges = edges;
    } else {
      cur = 0;
      for (long long i = 0; i <= n; i++)
        mark[i] = mark2[i][0] = mark2[i][1] = false;
      for (long long i = 0; i < m; i++) cut[i] = false;
      dfs2(s);
      bfs(s, 0);
      bfs(t, 1);
      for (long long i = 0; i < m; i++) {
        if (((check(s, t, v[i], u[i])) || check(s, t, u[i], v[i])) && cut[i] &&
            i != edgeId) {
          long long cost2 = cost + c[i];
          if (cost2 < res) {
            edges.second = i;
            res = cost2, fedges = edges;
          }
        }
      }
    }
    node = node2;
  }
  if (res == INF) {
    cout << -1 << "\n";
  } else {
    cout << res << "\n";
    if (fedges.second == -1)
      cout << 1 << "\n";
    else
      cout << 2 << "\n";
    cout << fedges.first + 1 << " ";
    if (fedges.second != -1) cout << fedges.second + 1;
    cout << "\n";
  }
}
