#include <bits/stdc++.h>
using namespace std;
const int N = 1111;
const int M = 30333;
bool was[N], bad[M], used[N], br[M];
int tin[N], f[N], timer, w[M], mn = INT_MAX;
vector<int> ans;
vector<pair<int, int>> g[N];
bool dfs(int v, int end, vector<int>& p) {
  was[v] = true;
  if (v == end) {
    return true;
  }
  for (auto u : g[v]) {
    int to = u.first, id = u.second;
    if (!was[to] && !bad[id]) {
      if (dfs(to, end, p)) {
        p.push_back(id);
        return true;
      }
    }
  }
  return false;
}
void dfs1(int v, int ID = -1) {
  used[v] = true;
  tin[v] = f[v] = timer++;
  for (auto u : g[v]) {
    int to = u.first, id = u.second;
    if (id == ID || bad[id]) continue;
    if (used[to])
      f[v] = min(tin[to], f[v]);
    else {
      dfs1(to, id);
      f[v] = min(f[v], f[to]);
      if (f[to] > tin[v]) br[id] = true;
    }
  }
}
int main() {
  int n, m, s, t, u, v;
  scanf("%d%d", &n, &m);
  scanf("%d%d", &s, &t);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &u, &v, &w[i]);
    g[u].push_back(make_pair(v, i));
    g[v].push_back(make_pair(u, i));
  }
  vector<int> path;
  if (!dfs(s, t, path)) {
    printf("0\n0");
    return 0;
  }
  memset(was, false, sizeof(was));
  dfs(s, t, path);
  for (int id : path) {
    memset(was, false, sizeof(was));
    bad[id] = true;
    vector<int> path2;
    if (!dfs(s, t, path2)) {
      if (w[id] < mn) {
        mn = w[id];
        ans.clear();
        ans.push_back(id);
      }
    }
    timer = 0;
    memset(used, false, sizeof(used));
    memset(tin, 0, sizeof(tin));
    memset(f, 0, sizeof(f));
    memset(br, 0, sizeof(br));
    for (int i = 1; i <= n; i++)
      if (!used[i]) dfs1(i);
    for (int j : path2) {
      if (!bad[j] && br[j]) {
        if (w[id] + w[j] < mn) {
          mn = w[id] + w[j];
          ans.clear();
          ans.push_back(j);
          ans.push_back(id);
        }
      }
    }
    bad[id] = false;
  }
  if (mn == INT_MAX)
    puts("-1");
  else {
    printf("%d\n%d\n", mn, ans.size());
    for (int i : ans) printf("%d ", i);
  }
  return 0;
}
