#include <bits/stdc++.h>
using namespace std;
const long long maxn = 3e4 + 100;
const long long mod = 1e9 + 7;
const long long inf = 1e18;
long long n, m, w[maxn], h[maxn], d[maxn], s, t;
bool f = 1, is[maxn], vis[maxn];
vector<pair<long long, long long> > g[maxn];
vector<long long> ve;
pair<long long, long long> x;
pair<long long, pair<long long, long long> > ans;
void dfs(long long v) {
  long long u, e;
  vis[v] = 1;
  if (v == t) f = 0;
  for (long long i = 0; i < g[v].size(); i++) {
    u = g[v][i].first;
    e = g[v][i].second;
    if (vis[u]) continue;
    if (f) ve.push_back(e);
    dfs(u);
  }
  if (f) ve.pop_back();
  return;
}
bool solve(long long v, long long p) {
  long long u, e;
  bool fp = 0;
  if (v == t) fp = 1;
  vis[v] = 1;
  h[v] = inf;
  for (long long i = 0; i < g[v].size(); i++) {
    u = g[v][i].first;
    e = g[v][i].second;
    if (is[e]) continue;
    if (vis[u]) {
      if (e != p) h[v] = min(h[v], d[u]);
      continue;
    }
    d[u] = d[v] + 1;
    f = solve(u, e);
    if (f) fp = 1;
    if (h[u] >= d[u] && f) x = min(x, {w[e], e});
    h[v] = min(h[v], h[u]);
  }
  return fp;
}
int main() {
  long long v, u;
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m;
  cin >> s >> t;
  for (long long i = 1; i <= m; i++) {
    cin >> v >> u >> w[i];
    g[v].push_back({u, i});
    g[u].push_back({v, i});
  }
  ve.push_back(0);
  dfs(s);
  if (!vis[t]) {
    cout << "0\n0";
    return 0;
  }
  ans = {inf, {-1, -1}};
  for (long long i = 0; i < ve.size(); i++) {
    is[ve[i]] = 1;
    x = {inf, -1};
    fill(vis, vis + n + 1, 0);
    solve(s, -1);
    ans = min(ans, {x.first + w[ve[i]], {ve[i], x.second}});
    is[ve[i]] = 0;
  }
  if (ans.first == inf) {
    cout << -1;
    return 0;
  }
  cout << ans.first << '\n';
  if (ans.second.first == 0)
    cout << "1\n" << ans.second.second;
  else
    cout << "2\n" << ans.second.first << " " << ans.second.second;
  return 0;
}
