#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void smin(T &a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U>
inline void smax(T &a, U b) {
  if (a < b) a = b;
}
template <typename T>
inline void gn(T &first) {
  char c, sg = 0;
  while (c = getchar(), (c > '9' || c < '0') && c != '-')
    ;
  for ((c == '-' ? sg = 1, c = getchar() : 0), first = 0; c >= '0' && c <= '9';
       c = getchar())
    first = (first << 1) + (first << 3) + c - '0';
  if (sg) first = -first;
}
template <class T, class T1>
inline void gn(T &first, T1 &second) {
  gn(first);
  gn(second);
}
template <class T, class T1, class T2>
inline void gn(T &first, T1 &second, T2 &z) {
  gn(first);
  gn(second);
  gn(z);
}
template <typename T>
inline void print(T first) {
  if (first < 0) {
    putchar('-');
    return print(-first);
  }
  if (first < 10) {
    putchar('0' + first);
    return;
  }
  print(first / 10);
  putchar(first % 10 + '0');
}
template <typename T>
inline void println(T first) {
  print(first), putchar('\n');
}
template <typename T>
inline void printsp(T first) {
  print(first), putchar(' ');
}
template <class T, class T1>
inline void print(T first, T1 second) {
  printsp(first), println(second);
}
template <class T, class T1, class T2>
inline void print(T first, T1 second, T2 z) {
  printsp(first), printsp(second), println(z);
}
int power(int a, int b, int m, int ans = 1) {
  for (; b; b >>= 1, a = 1LL * a * a % m)
    if (b & 1) ans = 1LL * ans * a % m;
  return ans;
}
int E, head[1010], to[2 * 30030], nxt[2 * 30030];
int vst[1010], low[1010], bel[1010];
int top, st[1010];
int ind, cnt;
void init(int n) {
  E = top = ind = cnt = 0;
  for (int i = 1; i <= n; i++) head[i] = -1, vst[i] = 0;
}
void add_edge(int u, int v) {
  nxt[E] = head[u];
  to[E] = v;
  head[u] = E++;
  nxt[E] = head[v];
  to[E] = u;
  head[v] = E++;
}
int id;
void dfs(int u, int pre = -1) {
  vst[u] = low[u] = ++ind;
  st[++top] = u;
  for (int e = head[u]; e != -1; e = nxt[e]) {
    int v = to[e];
    if ((e >> 1) == id) continue;
    if (!vst[v])
      dfs(v, e), low[u] = min(low[u], low[v]);
    else if ((e ^ pre) != 1)
      low[u] = min(low[u], vst[v]);
  }
  if (vst[u] == low[u]) {
    ++cnt;
    while (1) {
      bel[st[top]] = cnt;
      if (st[top--] == u) break;
    }
  }
}
pair<pair<int, int>, int> edge[30030];
int n, m, S, T;
vector<pair<pair<int, int>, int> > adj[1010];
pair<int, int> redfs(int u, int fa = 0,
                     pair<int, int> mn = pair<int, int>(0x3f3f3f3f, -1)) {
  if (u == bel[T]) return mn;
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i].second;
    if (v == fa) continue;
    pair<int, int> res = redfs(v, u, min(mn, adj[u][i].first));
    if (res.first) return res;
  }
  return pair<int, int>(0, -1);
}
long long calc(int &edgeid) {
  for (int i = 1; i <= n; i++) vst[i] = 0;
  ind = cnt = top = 0;
  for (int i = 1; i <= n; i++)
    if (!vst[i]) dfs(i);
  if (bel[S] == bel[T]) return 0x3f3f3f3f3f3f3f3fLL;
  for (int i = 0; i < m; i++)
    if (i != id) {
      int u = bel[edge[i].first.first];
      int v = bel[edge[i].first.second];
      int w = edge[i].second;
      if (u == v) continue;
      adj[u].push_back(pair<pair<int, int>, int>(pair<int, int>(w, i), v));
      adj[v].push_back(pair<pair<int, int>, int>(pair<int, int>(w, i), u));
    }
  pair<int, int> res = redfs(bel[S]);
  for (int i = 1; i <= cnt; i++) adj[i].clear();
  edgeid = res.second;
  return res.first;
}
vector<int> path;
int flag[1010], pre[1010];
bool bfs() {
  queue<int> q;
  q.push(S);
  flag[S] = 1;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    if (u == T) {
      while (u != S) path.push_back(pre[u] >> 1), u = to[pre[u] ^ 1];
      return true;
    }
    for (int e = head[u]; ~e; e = nxt[e]) {
      int v = to[e];
      if (flag[v]) continue;
      flag[v] = 1;
      q.push(v);
      pre[v] = e;
    }
  }
  return false;
}
int main() {
  gn(n, m);
  gn(S, T);
  init(n);
  for (int i = 0, u, v, w; i < m; i++) {
    gn(u, v, w);
    add_edge(u, v);
    edge[i] = pair<pair<int, int>, int>(pair<int, int>(u, v), w);
  }
  if (!bfs()) return puts("0\n0"), 0;
  path.push_back(-1);
  long long ans = 0x3f3f3f3f3f3f3f3fLL;
  vector<int> vec;
  for (int i = 0; i < path.size(); i++) {
    id = path[i];
    int edgeid;
    long long tmp = calc(edgeid) + (id >= 0 ? edge[id].second : 0);
    if (ans > tmp) {
      ans = tmp;
      vec.clear();
      if (id >= 0) vec.push_back(id);
      if (edgeid >= 0) vec.push_back(edgeid);
    }
  }
  if (ans < 2e9 + 10) {
    println(ans);
    println(vec.size());
    for (int i = 0; i < vec.size(); i++) printsp(vec[i] + 1);
  } else
    puts("-1");
  return 0;
}
