#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1005;
const int MAXM = 30005;
const int INF = 2 * (0X3F3F3F3F);
int N, M, Cnt, s, t, val[MAXM];
int dfn[MAXN], low[MAXN], vis[MAXN];
vector<int> P[MAXN], T[MAXN], ID[MAXN];
vector<int> Bi, BP[MAXN], BPV[MAXN];
int stac[MAXN], len;
int Anscnt, bel[MAXN];
int Ans1, Ans2 = INF, ans[MAXN];
void Add(int x, int y, int z, int id) {
  P[x].push_back(y);
  T[x].push_back(z);
  ID[x].push_back(id);
}
void DFS(int u, int fad, int uad) {
  stac[++len] = u;
  dfn[u] = low[u] = ++Cnt;
  int size = P[u].size();
  for (int i = 0; i < size; i++) {
    int v = P[u][i];
    if (ID[u][i] == uad) continue;
    if (dfn[v]) {
      if (ID[u][i] == fad) continue;
      if (dfn[v] >= dfn[u]) continue;
      low[u] = min(low[u], dfn[v]);
      continue;
    }
    DFS(v, ID[u][i], uad);
    low[u] = min(low[u], low[v]);
  }
  if (low[u] == dfn[u]) {
    Anscnt++;
    while (1) {
      int x = stac[len--];
      bel[x] = Anscnt;
      if (x == u) break;
    }
  }
}
int dfs(int u, int fad) {
  vis[u] = 1;
  if (u == t) return 1;
  int size = P[u].size();
  for (int i = 0; i < size; i++) {
    int v = P[u][i];
    if (vis[v]) continue;
    if (dfs(v, ID[u][i])) {
      Bi.push_back(ID[u][i]);
      return 1;
    }
  }
  return 0;
}
void Init(int id) {
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= Anscnt; i++) BP[i].clear(), BPV[i].clear();
  for (int i = 1; i <= N; i++) {
    if (!bel[i]) continue;
    int size = P[i].size();
    for (int j = 0; j < size; j++) {
      int u = bel[i], v = bel[P[i][j]];
      if (u == v) continue;
      if (ID[i][j] == id) continue;
      BP[u].push_back(v);
      BPV[u].push_back(ID[i][j]);
      BP[v].push_back(u);
      BPV[v].push_back(ID[i][j]);
    }
  }
}
int D(int u, int ed) {
  int ret = -1;
  vis[u] = 1;
  if (u == ed) return 0;
  int size = BP[u].size();
  for (int i = 0; i < size; i++) {
    int v = BP[u][i];
    if (vis[v]) continue;
    int x = D(v, ed);
    if (x == -1) continue;
    ret = BPV[u][i];
    if (val[ret] > val[x]) ret = x;
  }
  return ret;
}
int main() {
  scanf("%d%d%d%d", &N, &M, &s, &t);
  for (int i = 1, x, y, z; i <= M; i++) {
    scanf("%d%d%d", &x, &y, &z);
    Add(x, y, z, i);
    Add(y, x, z, i);
    val[i] = z;
  }
  val[0] = INF;
  if (!dfs(s, 0)) {
    printf("0\n0\n");
    return 0;
  }
  int size = Bi.size();
  for (int i = 0; i < size; i++) {
    Anscnt = Cnt = len = 0;
    int ret = val[Bi[i]];
    memset(dfn, 0, sizeof(dfn));
    memset(low, 0, sizeof(low));
    memset(bel, 0, sizeof(bel));
    DFS(s, 0, Bi[i]);
    if (bel[s] == bel[t]) continue;
    if (bel[t] == 0) {
      if (ret < Ans2) {
        Ans2 = ret;
        Ans1 = 1;
        ans[Ans1] = Bi[i];
      }
      continue;
    }
    Init(Bi[i]);
    int x = D(bel[s], bel[t]);
    if (x == -1) continue;
    ret += val[x];
    if (ret < Ans2) {
      Ans2 = ret;
      Ans1 = 2;
      ans[1] = Bi[i];
      ans[2] = x;
    }
  }
  if (Ans2 == INF) {
    printf("-1\n");
    return 0;
  }
  printf("%d\n%d\n", Ans2, Ans1);
  sort(ans + 1, ans + Ans1 + 1);
  for (int i = 1; i < Ans1; i++) printf("%d ", ans[i]);
  printf("%d\n", ans[Ans1]);
}
