#include <bits/stdc++.h>
using namespace std;
int const lim = 1003;
vector<pair<int, int> > bridge;
int n, m, x;
int s, d;
vector<int> adj[lim + 3], cost[lim + 3][lim + 3];
int mn[lim + 3], val[lim + 3];
bool vis[lim + 3];
int edge[lim + 3][lim + 3];
int from[lim + 3];
int t = 0;
vector<int> path, path1;
int path_e[lim + 3][lim + 3], path_ee[lim + 3][lim + 3];
map<pair<pair<int, int>, int>, vector<int> > indexes;
void mem() {
  memset(vis, false, sizeof vis);
  memset(mn, false, sizeof mn);
  memset(val, false, sizeof val);
  bridge.clear();
  t = 0;
}
void findb(int u, int p) {
  vis[u] = true;
  val[u] = mn[u] = ++t;
  for (int i = 0; i < adj[u].size(); i++) {
    int che = adj[u][i];
    int uu = u, vv = che;
    if (uu < vv) swap(uu, vv);
    if (vis[che] || !edge[uu][vv]) {
      if (che != p && edge[uu][vv]) mn[u] = min(mn[u], val[che]);
      continue;
    }
    findb(che, u);
    mn[u] = min(mn[u], mn[che]);
    if (mn[che] > val[u]) bridge.push_back(make_pair(uu, vv));
  }
}
void findpath(int u) {
  vis[u] = true;
  for (int i = 0; i < adj[u].size(); i++) {
    int che = adj[u][i];
    int uu = u, vv = che;
    if (uu < vv) swap(uu, vv);
    if (edge[uu][vv] == 0) continue;
    if (!vis[che]) from[che] = u, findpath(che);
  }
}
int main() {
  int u, v, c;
  cin >> n >> m;
  cin >> s >> d;
  int ans = INT_MAX;
  pair<int, int> out;
  out.first = out.second = -1;
  for (int i = 0; i < m; i++) {
    scanf("%d%d%d", &u, &v, &c);
    if (v > u) swap(u, v);
    adj[u].push_back(v);
    adj[v].push_back(u);
    edge[u][v]++;
    cost[u][v].push_back(c);
    indexes[make_pair(make_pair(u, v), c)].push_back(i + 1);
  }
  findpath(s);
  mem();
  if (!from[d]) {
    cout << 0 << endl << 0 << endl;
    return 0;
  }
  u = d;
  while (from[u])
    path.push_back(u), path_e[u][from[u]] = path_e[from[u]][u] = true,
                       u = from[u];
  path.push_back(s);
  reverse(path.begin(), path.end());
  mem();
  findb(s, s);
  for (int i = 0; i < bridge.size(); i++) {
    u = bridge[i].first;
    v = bridge[i].second;
    if (v > u) swap(u, v);
    if (edge[u][v] > 1) continue;
    if (path_e[u][v] && cost[u][v][0] < ans)
      ans = cost[u][v][0],
      out.first = indexes[make_pair(make_pair(u, v), cost[u][v][0])][0];
  }
  for (int j = 0; j < path.size() - 1; j++) {
    u = path[j], v = path[j + 1];
    if (u < v) swap(u, v);
    int val = cost[u][v][0];
    edge[u][v]--;
    if (edge[u][v] > 1) continue;
    mem();
    findb(s, s);
    memset(vis, 0, sizeof vis);
    memset(from, 0, sizeof from);
    path1.clear();
    findpath(s);
    int uu = d;
    while (from[uu])
      path1.push_back(uu), path_ee[uu][from[uu]] = path_ee[from[uu]][uu] = true,
                           uu = from[uu];
    path1.push_back(s);
    reverse(path1.begin(), path1.end());
    for (int i = 0; i < bridge.size(); i++) {
      int shit = 0;
      int vval = val;
      int uu = bridge[i].first, vv = bridge[i].second;
      if (uu < vv) swap(uu, vv);
      if (edge[uu][vv] > 1 || !path_ee[uu][vv]) continue;
      if (uu == u && vv == v)
        shit = cost[u][v][1];
      else
        shit = cost[uu][vv][0];
      vval += shit;
      if (vval < ans)
        ans = vval,
        out.first = indexes[make_pair(make_pair(u, v), cost[u][v][0])][0],
        out.second =
            indexes[make_pair(make_pair(uu, vv), shit)][(shit == val ? 1 : 0)];
    }
    for (int i = 0; i < path1.size() - 1; i++) {
      int uu = path1[i], vv = path1[i + 1];
      path_ee[uu][vv] = path_ee[vv][uu] = false;
    }
    edge[u][v]++;
  }
  if (ans == INT_MAX) {
    cout << -1 << endl;
    return 0;
  }
  cout << ans << endl;
  if (out.second == -1)
    cout << 1 << endl << out.first;
  else
    cout << 2 << endl << out.first << " " << out.second;
}
