#include <bits/stdc++.h>
using namespace std;
const int INF = 2000000005;
const int maxe = 3e4 + 1;
const int maxn = 1001;
int n, m;
int s, t;
int x[maxe], y[maxe], w[maxe];
vector<int> G[maxn], K[maxn];
vector<pair<int, int> > g[maxn];
int vis[maxn], vid = 0;
int ansi;
vector<int> ansv;
vector<int> path;
int pre[maxn], low[maxn], dfs_clock;
int maybe_is_bridge[maxe], bid;
int color[maxn], cid;
vector<int> bridge_from_s_to_t;
void dfs(vector<int> G[maxn], int u) {
  vis[u] = vid;
  for (auto e : G[u]) {
    int v = x[e] == u ? y[e] : x[e];
    if (vis[v] != vid) dfs(G, v);
  }
}
void get_path(vector<int> G[maxn], int u, vector<int> &vec) {
  vis[u] = vid;
  if (u == t) path = vec;
  for (auto e : G[u]) {
    int v = x[e] == u ? y[e] : x[e];
    if (vis[v] != vid) {
      vec.push_back(e);
      get_path(G, v, vec);
      vec.pop_back();
    }
  }
}
int tarjan(int u, int fa) {
  int lowu = pre[u] = ++dfs_clock;
  for (auto e : K[u]) {
    int v = x[e] == u ? y[e] : x[e];
    if (!pre[v]) {
      int lowv = tarjan(v, u);
      lowu = min(lowu, lowv);
      if (lowv > pre[u]) {
        maybe_is_bridge[e] = bid;
      }
    } else if (pre[v] < pre[u] && v != fa) {
      lowu = min(lowu, pre[v]);
    }
  }
  return low[u] = lowu;
}
void make_color(int u) {
  color[u] = cid;
  for (auto e : K[u]) {
    if (maybe_is_bridge[e] == bid) continue;
    int v = x[e] == u ? y[e] : x[e];
    if (color[v] != cid) make_color(v);
  }
}
void dfs_g(int u, vector<int> &bridge) {
  vis[u] = vid;
  if (u == color[t]) {
    bridge_from_s_to_t = bridge;
  }
  for (auto e : g[u]) {
    if (vis[e.first] != vid) {
      bridge.push_back(e.second);
      dfs_g(e.first, bridge);
      bridge.pop_back();
    }
  }
}
int main() {
  vector<int> no_use;
  scanf("%d%d%d%d", &n, &m, &s, &t);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &x[i], &y[i], &w[i]);
    G[x[i]].push_back(i);
    G[y[i]].push_back(i);
  }
  vid++;
  dfs(G, s);
  if (vis[t] != vid) {
    puts("0\n0");
    return 0;
  }
  vid++;
  get_path(G, s, no_use);
  ansi = INF;
  for (auto e : path) {
    for (int i = 1; i <= n; i++) K[i].clear();
    memset(pre, 0, sizeof(pre));
    dfs_clock = 0;
    for (int i = 1; i <= m; i++) {
      if (i != e) {
        K[x[i]].push_back(i);
        K[y[i]].push_back(i);
      }
    }
    vid++;
    dfs(K, s);
    if (vis[t] != vid && w[e] < ansi) {
      ansi = w[e];
      ansv.clear();
      ansv.push_back(e);
      continue;
    }
    bid++;
    for (int i = 1; i <= n; i++) {
      if (!pre[i]) tarjan(i, -1);
    }
    memset(color, 0, sizeof(color));
    cid = 0;
    for (int i = 1; i <= n; i++) {
      if (!color[i]) {
        cid++;
        make_color(i);
      }
    }
    if (color[s] == color[t]) continue;
    for (int i = 1; i <= cid; i++) g[i].clear();
    for (int i = 1; i <= m; i++) {
      if (i == e) continue;
      if (color[x[i]] != color[y[i]]) {
        g[color[x[i]]].emplace_back(color[y[i]], i);
        g[color[y[i]]].emplace_back(color[x[i]], i);
      }
    }
    vid++;
    dfs_g(color[s], no_use);
    for (auto b : bridge_from_s_to_t) {
      if (w[e] + w[b] < ansi) {
        ansi = w[e] + w[b];
        ansv.clear();
        ansv.push_back(e);
        ansv.push_back(b);
      }
    }
  }
  if (ansi == INF) {
    puts("-1");
    return 0;
  }
  sort(ansv.begin(), ansv.end());
  printf("%d\n%d\n", ansi, (int)ansv.size());
  for (auto e : ansv) printf("%d ", e);
  return 0;
}
