#include <bits/stdc++.h>
using namespace std;
struct edge {
  int v, w, indx;
};
int invalid;
vector<int> visit(1005), chk(1005), height(1005), depth(1005), up(1005);
vector<edge> adj[1005];
void dfs(int node, int dest) {
  chk[node] = 1;
  if (node == dest) chk[node] = 2;
  up[node] = -1;
  for (auto x : adj[node]) {
    if (x.indx == invalid) continue;
    if (chk[x.v]) {
      if (depth[node] < depth[x.v])
        up[node]--;
      else if (depth[node] > depth[x.v])
        up[node]++;
      continue;
    }
    depth[x.v] = 1 + depth[node];
    dfs(x.v, dest);
    up[node] += up[x.v];
    chk[node] = max(chk[node], chk[x.v]);
  }
}
int main() {
  int i, j, k;
  int n, m, s, t;
  cin >> n >> m >> s >> t;
  for (i = 1; i <= m; ++i) {
    int u, v, w;
    scanf("%d %d %d", &u, &v, &w);
    adj[u].push_back({v, w, i});
    adj[v].push_back({u, w, i});
  }
  dfs(s, t);
  visit = chk;
  height = depth;
  if (visit[s] != 2) return puts("0\n0");
  int cur = s, mn = INT_MAX;
  vector<int> ans;
  while (cur != t) {
    for (auto x : adj[cur]) {
      if (visit[x.v] == 2 && height[x.v] > height[cur]) {
        invalid = x.indx;
        fill(chk.begin(), chk.end(), 0);
        dfs(s, t);
        if (chk[s] != 2) {
          if (x.w < mn) {
            mn = x.w;
            ans.clear();
            ans.push_back(x.indx);
          }
        }
        for (i = 1; i <= n; ++i) {
          for (auto y : adj[i]) {
            if (y.indx != invalid && chk[i] == 2 && chk[y.v] == 2 &&
                depth[i] < depth[y.v] && up[y.v] == 0) {
              if (x.w + y.w < mn) {
                mn = x.w + y.w;
                ans.clear();
                ans.push_back(x.indx);
                ans.push_back(y.indx);
              }
            }
          }
        }
        invalid = 0;
        cur = x.v;
        break;
      }
    }
  }
  if (mn == INT_MAX) return puts("-1");
  cout << mn << endl;
  cout << ans.size() << endl;
  for (i = 0; i < ans.size(); ++i) cout << ans[i] << " ";
}
