#include <bits/stdc++.h>
using namespace std;
const int N = 1e3, M = 3e4;
int n, m, src, dest, u[M], v[M], c[M], low[N], idx[N], vis[M], vs, dfs, p[N];
vector<pair<int, int> > g[N], G[N];
vector<int> br;
pair<int, int> qu[N];
void DFS(int v, int p, int d) {
  low[v] = idx[v] = ++dfs;
  for (int i = 0; i < (int)g[v].size(); ++i) {
    if (g[v][i].second == d) continue;
    int u = g[v][i].first;
    if (idx[u] == -1) {
      DFS(u, v, d);
      if (low[u] > idx[v]) {
        vis[g[v][i].second] = vs;
        br.push_back(g[v][i].second);
      }
      low[v] = min(low[v], low[u]);
    } else if (u != p)
      low[v] = min(low[v], low[u]);
  }
}
int find(int x) {
  if (x == p[x]) return x;
  return p[x] = find(p[x]);
}
int check(int d) {
  for (int i = 0; i < n; ++i) {
    p[i] = i;
    idx[i] = -1;
    G[i].clear();
  }
  ++vs;
  dfs = 0;
  br.clear();
  for (int i = 0; i < n; ++i)
    if (idx[i] == -1) DFS(i, -1, d);
  for (int i = 0; i < m; ++i)
    if (i != d && vis[i] != vs) p[find(u[i])] = find(v[i]);
  int S = find(src), D = find(dest);
  if (S == D) return -1;
  for (int i = 0; i < (int)br.size(); ++i) {
    int a = find(u[br[i]]), b = find(v[br[i]]);
    G[a].push_back(make_pair(b, br[i]));
    G[b].push_back(make_pair(a, br[i]));
  }
  int l = 0, r = 0;
  qu[r++] = make_pair(S, -1);
  vis[S] = ++vs;
  while (l < r) {
    int v = qu[l].first, id = qu[l].second;
    ++l;
    for (int i = 0; i < (int)G[v].size(); ++i) {
      int u = G[v][i].first, nj = id;
      if (vis[u] == vs) continue;
      if (id == -1 || c[G[v][i].second] < c[id]) nj = G[v][i].second;
      if (u == D) return nj;
      vis[u] = vs;
      qu[r++] = make_pair(u, nj);
    }
  }
  return -2;
}
int main() {
  scanf("%d%d%d%d", &n, &m, &src, &dest);
  --src, --dest;
  for (int i = 0; i < m; ++i) {
    scanf("%d%d%d", &u[i], &v[i], &c[i]);
    --u[i], --v[i];
    g[u[i]].push_back(make_pair(v[i], i));
    g[v[i]].push_back(make_pair(u[i], i));
  }
  queue<int> qu;
  memset(p, -1, sizeof p);
  qu.push(src);
  vis[src] = ++vs;
  while (!qu.empty()) {
    int v = qu.front();
    qu.pop();
    if (v == dest) break;
    for (int i = 0; i < (int)g[v].size(); ++i) {
      int u = g[v][i].first;
      if (vis[u] == vs) continue;
      p[u] = g[v][i].second;
      vis[u] = vs;
      qu.push(u);
    }
  }
  if (p[dest] == -1) {
    puts("0\n0");
    return 0;
  }
  vector<int> sol, path;
  int at = dest;
  while (at != src) {
    path.push_back(p[at]);
    if (u[p[at]] == at)
      at = v[p[at]];
    else
      at = u[p[at]];
  }
  int best = -1;
  for (int i = 0; i < (int)path.size(); ++i) {
    int need = check(path[i]);
    if (need == -1) continue;
    int sum = c[path[i]];
    if (need != -2) sum += c[need];
    if (best == -1 || sum < best) {
      best = sum;
      sol.clear();
      sol.push_back(path[i]);
      if (need != -2) sol.push_back(need);
    }
  }
  if (!sol.empty()) {
    printf("%d\n%d\n", best, (int)sol.size());
    for (int i = 0; i < (int)sol.size(); ++i)
      printf("%s%d", i ? " " : "", sol[i] + 1);
    puts("");
  } else
    puts("-1");
  return 0;
}
