#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const int N = 1001, inf = INT_MAX;
int n, m, s, t, ban = 0, mn = inf, ans = inf, ban2 = inf, h[N], dp[N], w[N * N];
bool hs[N], ht[N];
vector<int> ban_list, adj[N], id[N][N];
pair<int, int> res;
void tree(int v) {
  for (auto u : adj[v]) {
    if (!h[u]) {
      h[u] = 1;
      tree(u);
      int mn = inf, index;
      for (auto cur : id[u][v]) {
        if (mn > w[cur]) {
          mn = w[cur];
          index = cur;
        }
      }
      ban_list.push_back(index);
    }
  }
}
void dfs(int v, int p) {
  if (v == s) {
    hs[v] = 1;
  }
  if (v == t) {
    ht[v] = 1;
  }
  for (auto u : adj[v]) {
    if (u == p || (id[u][v][0] == ban && id[u][v].size() == 1)) {
      continue;
    }
    if (h[u] == 0) {
      h[u] = h[v] + 1;
      dfs(u, v);
      hs[v] = max(hs[v], hs[u]);
      ht[v] = max(ht[v], ht[u]);
      dp[v] += dp[u];
    } else if (h[u] < h[v]) {
      dp[v]++;
    } else {
      dp[v]--;
    }
  }
  if (h[v] > 1 && dp[v] == 0) {
    if ((hs[v] && !ht[v]) || (!hs[v] && ht[v])) {
      int cur = id[v][p][0];
      if (cur == ban) {
        cur = id[v][p][1];
        if (id[v][p].size() == 2) {
          if (mn > w[cur]) {
            mn = w[cur];
            ban2 = cur;
          }
        }
      } else if (id[v][p].size() == 1 ||
                 (id[v][p].size() == 2 && id[v][p][1] == ban)) {
        if (mn > w[cur]) {
          mn = w[cur];
          ban2 = cur;
        }
      }
    }
  }
}
int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin >> n >> m >> s >> t;
  for (int i = 1, u, v, w; i <= m; i++) {
    cin >> u >> v >> w;
    if (u == v) {
      continue;
    }
    if (id[u][v].empty()) {
      adj[u].push_back(v);
      adj[v].push_back(u);
    }
    id[u][v].push_back(i);
    id[v][u].push_back(i);
    ::w[i] = w;
  }
  for (int i = 1; i <= n; i++) {
    if (!h[i]) {
      h[i] = 1;
      tree(i);
    }
  }
  memset(h, 0, sizeof h);
  for (int i = 1; i <= n; i++) {
    if (!h[i]) {
      h[i] = 1;
      dfs(i, 0);
      if ((h[s] && !h[t]) || (!h[s] && h[t])) {
        cout << "0\n0";
        return 0;
      }
    }
  }
  for (auto ban : ban_list) {
    ::ban = ban;
    mn = inf;
    memset(h, 0, sizeof h);
    memset(dp, 0, sizeof dp);
    memset(hs, 0, sizeof hs);
    memset(ht, 0, sizeof ht);
    ban2 = inf;
    for (int i = 1; i <= n; i++) {
      if (!h[i]) {
        h[i] = 1;
        dfs(i, 0);
        if ((h[s] && !h[t]) || (!h[s] && h[t])) {
          mn = 0;
          ban2 = 0;
          break;
        }
      }
    }
    if (ban2 != inf && ans > w[ban] + mn) {
      ans = w[ban] + mn;
      res = {ban, ban2};
    }
  }
  if (ans == inf) {
    cout << -1;
    return 0;
  }
  if (ans == 0) {
    cout << 0;
    return 0;
  }
  if (!res.second) {
    cout << ans << "\n1\n" << res.first;
    return 0;
  }
  cout << ans << "\n2\n" << res.first << ' ' << res.second;
}
