#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e4 + 1;
int n, m, s, t, u[maxn], v[maxn];
const long long oo = (long long)1e18;
long long w[maxn];
vector<int> e[maxn];
int p1[maxn], use[maxn], p2[maxn], cnt, num[maxn], low[maxn], bridge[maxn];
queue<int> qu;
void OpenFile() {
  freopen(
      "Break Up"
      ".INP",
      "r", stdin);
  freopen(
      "Break Up"
      ".OUT",
      "w", stdout);
}
void Enter() {
  cin >> n >> m;
  cin >> s >> t;
  for (int i = 1; i <= m; ++i) {
    cin >> u[i] >> v[i] >> w[i];
    if (u[i] != v[i]) {
      e[u[i]].push_back(i);
      e[v[i]].push_back(i);
    }
  }
  w[0] = +oo;
}
void Find_road(int p[], int ban) {
  fill(p, p + n + 1, -1);
  p[s] = 0;
  qu.push(s);
  while (!qu.empty()) {
    int s = qu.front();
    qu.pop();
    int t;
    for (int i : e[s]) {
      if (i == ban) continue;
      if (s == u[i])
        t = v[i];
      else
        t = u[i];
      if (p[t] == -1) {
        p[t] = s;
        use[t] = i;
        qu.push(t);
      }
    }
  }
}
void Init() {}
void DFS(int s, int p, int ban) {
  num[s] = low[s] = ++cnt;
  bool fl = 0;
  int t;
  for (int i : e[s]) {
    if (i == ban) continue;
    if (s == u[i])
      t = v[i];
    else
      t = u[i];
    if (t == p && !fl) {
      fl = 1;
      continue;
    }
    if (num[t])
      low[s] = min(low[s], num[t]);
    else {
      DFS(t, s, ban);
      low[s] = min(low[s], low[t]);
      if (low[t] >= num[t]) bridge[t] = i;
    }
  }
}
int New_road(int ban) {
  fill(num, num + n + 1, 0);
  fill(low, low + n + 1, 0);
  fill(bridge, bridge + n + 1, -1);
  cnt = 0;
  DFS(s, s, ban);
  Find_road(p2, ban);
  if (p2[t] == -1) return -1;
  int mn = 0;
  for (int x = t; x != s; x = p2[x])
    if (bridge[x] != -1)
      if (w[bridge[x]] < w[mn]) mn = bridge[x];
  return mn;
}
long long W(int i) {
  if (i == -1)
    return 0;
  else
    return w[i];
}
void Solve() {
  Find_road(p1, -1);
  if (p1[t] == -1) {
    cout << 0 << '\n' << 0;
    return;
  }
  int res1, res2;
  res1 = res2 = 0;
  for (int x = t; x != s; x = p1[x]) {
    int i1 = use[x];
    int i2 = New_road(use[x]);
    if (W(res1) + W(res2) > W(i1) + W(i2)) {
      res1 = i1;
      res2 = i2;
    }
  }
  if (res1 == 0 || res2 == 0)
    cout << -1;
  else {
    cout << W(res1) + W(res2) << '\n';
    if (res2 == -1)
      cout << 1 << '\n' << res1;
    else
      cout << 2 << '\n' << res1 << ' ' << res2;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  Enter();
  Init();
  Solve();
}
