#include <bits/stdc++.h>
using namespace std;
void fen() { cout << "---------------" << endl; }
const int maxn = 1010;
const int maxM = 30010;
int n, m, S, T;
struct node {
  int u, v, w, nxt, id;
} g[2 * maxM];
int adj[maxn], e;
void add(int u, int v, int w, int i) {
  g[e] = (node){u, v, w, adj[u], i};
  adj[u] = e++;
}
void init() {
  scanf("%d%d%d%d", &n, &m, &S, &T);
  int x, y, z;
  memset(adj, -1, sizeof(adj));
  e = 1;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &x, &y, &z);
    add(x, y, z, i);
    add(y, x, z, i);
  }
}
int pa[maxM], opa[maxM];
bool cut[maxM], vis[maxn];
bool findp(int x, int pre) {
  vis[x] = 1;
  if (x == T) return 1;
  for (int i = adj[x]; i != -1; i = g[i].nxt) {
    int v = g[i].v;
    if (vis[v] || cut[g[i].id] || g[i].id == pre) continue;
    if (findp(v, g[i].id)) {
      pa[++pa[0]] = g[i].id;
      return 1;
    }
  }
  return 0;
}
bool Find_path() {
  memset(vis, 0, sizeof(vis));
  pa[0] = 0;
  return findp(S, 0);
}
int low[maxn], dfn[maxn], stp;
bool bri[maxM];
void tarjan(int x, int pre) {
  dfn[x] = low[x] = ++stp;
  for (int i = adj[x]; i != -1; i = g[i].nxt) {
    int v = g[i].v;
    if (g[i].id == pre || cut[g[i].id]) continue;
    if (dfn[v] == -1) {
      tarjan(v, g[i].id);
      low[x] = min(low[x], low[v]);
      if (low[v] > dfn[x]) {
        bri[g[i].id] = 1;
      }
    } else
      low[x] = min(low[x], dfn[v]);
  }
}
void Find_Bri() {
  memset(dfn, -1, sizeof(dfn));
  stp = 0;
  memset(bri, 0, sizeof(bri));
  tarjan(S, -1);
}
vector<int> ans;
void ha() {
  for (int i = 1; i <= pa[0]; i++) {
    cout << pa[i] << "  " << g[2 * pa[i]].u << "  " << g[2 * pa[i]].v << " "
         << g[2 * pa[i]].w << endl;
  }
  cout << endl;
}
void work() {
  if (!Find_path()) {
    cout << 0 << endl << 0 << endl;
    return;
  }
  Find_Bri();
  int mn = 0x7fffffff;
  for (int i = 1; i <= pa[0]; i++)
    if (bri[pa[i]] && g[2 * pa[i]].w < mn) {
      ans.clear(), ans.push_back(pa[i]), mn = g[2 * pa[i]].w;
    }
  memcpy(opa, pa, sizeof(opa));
  for (int i = 1; i <= opa[0]; i++) {
    cut[opa[i]] = 1;
    if (!Find_path()) {
      cut[opa[i]] = 0;
      continue;
    }
    Find_Bri();
    for (int j = 1; j <= pa[0]; j++) {
      if (bri[pa[j]] && g[2 * opa[i]].w + g[2 * pa[j]].w < mn) {
        ans.clear();
        ans.push_back(opa[i]);
        ans.push_back(pa[j]);
        mn = g[2 * opa[i]].w + g[2 * pa[j]].w;
      }
    }
    cut[opa[i]] = 0;
  }
  if (mn == 0x7fffffff) {
    cout << -1 << endl;
    return;
  }
  cout << mn << endl;
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
}
int main() {
  init();
  work();
}
