#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 2, M = 3e4 + 5;
int a[M], b[M], w[M], dontgo, d[N], pos = 0, can[N], par[N];
vector<int> path, adj[N];
void dfs(int x, int prev) {
  int i, u, v;
  d[x] = can[x] = ++pos;
  for (i = 0; i < adj[x].size(); ++i) {
    u = adj[x][i];
    if (prev != u && u != dontgo) {
      v = a[u] ^ b[u] ^ x;
      if (d[v])
        can[x] = min(can[x], d[v]);
      else {
        dfs(v, u);
        par[v] = u;
        can[x] = min(can[x], can[v]);
      }
    }
  }
}
long long W = 2e9 + 5, R1 = -1, R2 = -1;
void sol(long long w, int x, int y) {
  if (W > w) W = w, R1 = x, R2 = y;
}
int main() {
  int s, t, n, m, i, j;
  cin >> n >> m >> s >> t;
  for (i = 1; i <= m; ++i)
    scanf("%d%d%d", &a[i], &b[i], &w[i]), adj[a[i]].push_back(i),
        adj[b[i]].push_back(i);
  dfs(s, -1);
  if (d[t] == 0) {
    printf("0\n0\n");
    return 0;
  }
  int u, v, node = t, pp;
  while (node != s) {
    pp = node ^ a[par[node]] ^ b[par[node]];
    if (d[pp] < can[node])
      sol(w[par[node]], par[node], -1);
    else
      path.push_back(par[node]);
    node = pp;
  }
  for (i = 0; i < path.size(); ++i) {
    u = path[i];
    memset(can, 0, sizeof(can));
    memset(d, 0, sizeof(d));
    dontgo = u;
    dfs(s, -1);
    node = t;
    while (node != s) {
      pp = node ^ a[par[node]] ^ b[par[node]];
      if (d[pp] < can[node]) sol(w[par[node]] + w[u], par[node], u);
      node = pp;
    }
  }
  if (W == 2e9 + 5) {
    printf("-1\n");
  } else {
    cout << W << endl;
    cout << (R1 != -1) + (R2 != -1) << endl;
    if (R1 != -1) cout << R1 << " ";
    if (R2 != -1) cout << R2;
    cout << endl;
  }
}
