#include <bits/stdc++.h>
using namespace std;
const int Mod = 1e9 + 7;
const int N = 1e3 + 100;
const int M = 3e4 + 100;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
inline long long dpow(long long a, long long b) {
  long long r = 1, t = a;
  while (b) {
    if (b & 1) r = (r * t) % Mod;
    b >>= 1;
    t = (t * t) % Mod;
  }
  return r;
}
inline long long fpow(long long a, long long b) {
  long long r = 1, t = a;
  while (b) {
    if (b & 1) r = (r * t);
    b >>= 1;
    t = (t * t);
  }
  return r;
}
vector<pair<int, int> > G[N << 1];
vector<int> g;
int dfn[N], low[N], n, m, cnt;
int val[M], sp, tp;
int edge[M], res;
bool vis[N], cut[M];
int ID[5], ans;
bool path(int x) {
  if (x == tp) return true;
  vis[x] = true;
  for (auto it : G[x]) {
    int v = it.first, id = it.second;
    if (!vis[v] && path(v)) {
      edge[++res] = id;
      return true;
    }
  }
  return false;
}
bool dfs(int x, int no) {
  if (x == tp) return true;
  vis[x] = true;
  for (auto it : G[x]) {
    int v = it.first;
    int id = it.second;
    if (id != no && !vis[v] && dfs(v, no)) {
      g.push_back(id);
      return true;
    }
  }
  return false;
}
void tarjan(int x, int fa, int no) {
  dfn[x] = low[x] = ++cnt;
  for (auto it : G[x]) {
    int v = it.first, id = it.second;
    if (id == fa || id == no) continue;
    if (!dfn[v]) {
      tarjan(v, id, no);
      low[x] = min(low[x], low[v]);
      if (low[v] > dfn[x]) cut[id] = true;
    } else
      low[x] = min(low[x], dfn[v]);
  }
}
int main() {
  cin >> n >> m >> sp >> tp;
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d %d %d", &u, &v, &val[i]);
    G[u].push_back({v, i});
    G[v].push_back({u, i});
  }
  if (!path(sp)) printf("0\n0\n"), exit(0);
  ans = INT_MAX;
  for (int i = 1; i <= res; i++) {
    int ii = edge[i];
    memset(vis, 0, sizeof(vis)), g.clear();
    if (!dfs(sp, ii)) {
      if (val[ii] < ans) ans = val[ii], ID[1] = ii, ID[2] = 0;
    } else {
      cnt = 0;
      memset(dfn, 0, sizeof(dfn)), memset(low, 0, sizeof(low));
      memset(cut, 0, sizeof(cut));
      for (int j = 1; j <= n; j++) {
        if (!dfn[j]) tarjan(j, 0, ii);
      }
      for (auto it : g) {
        if (cut[it] && val[it] + val[ii] < ans)
          ans = val[it] + val[ii], ID[1] = ii, ID[2] = it;
      }
    }
  }
  if (ans == INT_MAX)
    printf("-1\n");
  else {
    printf("%d\n", ans);
    if (!ID[2])
      printf("1\n%d\n", ID[1]);
    else
      printf("2\n%d %d\n", ID[1], ID[2]);
  }
  return 0;
}
