#include <bits/stdc++.h>
using namespace std;
const int N = 1111;
const int INF = 2e9 + 111;
int n, m, s, t, E[N * N], res;
struct data {
  int v, id;
  data() {}
  data(int a, int b) {
    v = a;
    id = b;
  }
};
vector<data> Adj[N];
bool vst[N], Bridge[N * N];
int Fa[N], edgeId[N], Num[N], Low[N], counter;
vector<int> Path;
int vex[2];
vector<int> FindPath(int block) {
  vector<int> ret;
  queue<int> Qu;
  memset(vst, 0, sizeof(vst));
  memset(Fa, 255, sizeof(Fa));
  Qu.push(s);
  vst[s] = 1;
  while (!Qu.empty()) {
    int u = Qu.front();
    Qu.pop();
    for (int i = 0; i < (int)Adj[u].size(); i++) {
      int v = Adj[u][i].v;
      int id = Adj[u][i].id;
      if (id == block || vst[v]) continue;
      Fa[v] = u;
      edgeId[v] = id;
      Qu.push(v);
      vst[v] = 1;
    }
  }
  if (Fa[t] == -1) return ret;
  for (int x = t; x != s; x = Fa[x]) {
    ret.push_back(edgeId[x]);
  }
  return ret;
}
void FindBridge(int u, int pid, int block) {
  Num[u] = Low[u] = ++counter;
  vst[u] = 1;
  for (int i = 0; i < (int)Adj[u].size(); i++) {
    int v = Adj[u][i].v;
    int id = Adj[u][i].id;
    if (id == block || id == pid) continue;
    if (!vst[v]) {
      FindBridge(v, id, block);
      Low[u] = min(Low[u], Low[v]);
      if (Low[v] > Num[u]) Bridge[id] = 1;
    } else
      Low[u] = min(Low[u], Num[v]);
  }
}
void FindMin(int block) {
  memset(vst, 0, sizeof(vst));
  memset(Bridge, 0, sizeof(Bridge));
  counter = 0;
  FindBridge(s, -1, block);
  vector<int> V = FindPath(block);
  for (int i = 0; i < (int)V.size(); i++) {
    if (Bridge[V[i]] && res > E[block] + E[V[i]]) {
      res = E[block] + E[V[i]];
      vex[0] = block;
      vex[1] = V[i];
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  cin >> s >> t;
  for (int i = 1; i <= m; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    Adj[u].push_back(data(v, i));
    Adj[v].push_back(data(u, i));
    E[i] = w;
  }
  Path = FindPath(0);
  if (Path.size() == 0) {
    cout << 0 << '\n' << 0;
    return 0;
  }
  res = INF;
  FindMin(0);
  for (int i = 0; i < (int)Path.size(); i++) {
    FindMin(Path[i]);
  }
  if (res == INF)
    cout << -1;
  else {
    cout << res << '\n';
    if (vex[0] == 0)
      cout << 1 << '\n' << vex[1];
    else
      cout << 2 << '\n' << vex[0] << ' ' << vex[1];
  }
  return 0;
}
