#include <bits/stdc++.h>
using namespace std;
struct edge {
  int v, c, id;
};
const int NMAX = 1111;
const int MMAX = 33333;
edge edges[MMAX];
vector<edge> g[NMAX];
int N, M;
vector<int> bfs(int s, int t, int cut) {
  vector<pair<int, int>> back(N + 1);
  back[s] = {s, 0};
  queue<int> q;
  q.push(s);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (const auto& e : g[u]) {
      if (e.id == cut) continue;
      int v = e.v;
      if (!back[v].first) {
        back[v] = {u, e.id};
        q.push(v);
      }
    }
  }
  vector<int> ret;
  if (!back[t].first) return ret;
  int it = t;
  while (it != s) {
    ret.push_back(back[it].second);
    it = back[it].first;
  }
  return ret;
}
vector<int> cand;
int lowlink[NMAX], preorder[NMAX];
int vcnt;
bool dfs(int here, int cut, int fa, int target) {
  preorder[here] = ++vcnt;
  lowlink[here] = preorder[here];
  bool ret = (here == target);
  for (const auto& e : g[here]) {
    if (e.id == cut) continue;
    if (e.id == fa) continue;
    bool b = false;
    int there = e.v;
    if (!preorder[there]) {
      b = dfs(there, cut, e.id, target);
      if (b) ret = true;
    }
    lowlink[here] = min(lowlink[here], lowlink[there]);
    if (b && lowlink[there] == preorder[there]) cand.push_back(e.id);
  }
  return ret;
}
int main() {
  scanf("%d%d", &N, &M);
  int s, t;
  scanf("%d%d", &s, &t);
  for (int i = 1; i <= M; i++) {
    int u, v, c;
    scanf("%d%d%d", &u, &v, &c);
    if (u == v) continue;
    g[u].push_back({v, c, i});
    g[v].push_back({u, c, i});
    edges[i] = {-1, c, i};
  }
  auto v = bfs(s, t, 0);
  if (v.empty()) {
    printf("0\n0");
    return 0;
  }
  pair<int, vector<int>> ans = {0x7fFFffFF, {}};
  dfs(s, 0, 0, t);
  for (int b : cand) ans = min(ans, {edges[b].c, {b}});
  for (int e : v) {
    for (int i = 1; i <= N; i++) preorder[i] = lowlink[i] = 0;
    vcnt = 0;
    cand.clear();
    dfs(s, e, 0, t);
    for (int b : cand) {
      ans = min(ans, {edges[e].c + edges[b].c, {e, b}});
    }
  }
  if (ans.first == 0x7fFFffFF) {
    printf("-1");
    return 0;
  }
  printf("%d\n%d\n", ans.first, ans.second.size());
  for (int i : ans.second) printf("%d ", i);
}
