#include <bits/stdc++.h>
using namespace std;
void fre() {
  freopen("c://test//input.in", "r", stdin);
  freopen("c://test//output.out", "w", stdout);
}
template <class T1, class T2>
inline void gmax(T1 &a, T2 b) {
  if (b > a) a = b;
}
template <class T1, class T2>
inline void gmin(T1 &a, T2 b) {
  if (b < a) a = b;
}
const int N = 1010, M = 6e5 + 10, Z = 1e9 + 7, ms63 = 0x3f3f3f3f;
int casenum, casei;
int n, m;
int ST, ED;
bool vis[N];
pair<int, int> pre[N];
int first[N], id;
int w[M], c[M], nxt[M];
bool use[M >> 1];
void ins(int x, int y, int z) {
  w[++id] = y;
  c[id] = z;
  nxt[id] = first[x];
  first[x] = id;
}
void dfs(int x) {
  vis[x] = 1;
  for (int z = first[x]; z; z = nxt[z]) {
    int y = w[z];
    if (vis[y]) continue;
    pre[y] = make_pair(x, z);
    dfs(y);
  }
}
int dfn[N], low[N], tim;
int sta[N], top;
bool insta[N];
int ans1, ans2;
int ans;
vector<int> ANS;
void update() {
  if (c[ans1 << 1] + c[ans2 << 1] < ans) {
    ans = c[ans1 << 1] + c[ans2 << 1];
    ANS.clear();
    ANS.push_back(ans1);
    if (ans2) ANS.push_back(ans2);
  }
}
void tarjan(int x, int lastz) {
  dfn[x] = low[x] = ++tim;
  sta[++top] = x;
  insta[x] = 1;
  for (int z = first[x]; z; z = nxt[z])
    if (use[z >> 1]) {
      if ((z ^ lastz) == 1) continue;
      int y = w[z];
      if (dfn[y] == 0) {
        tarjan(y, z);
        gmin(low[x], low[y]);
      }
      if (insta[y]) gmin(low[x], dfn[y]);
      if (low[y] > dfn[x]) {
        if (dfn[ED] >= dfn[y]) {
          ans2 = z >> 1;
          update();
        }
      }
    }
  if (dfn[x] == low[x]) {
    while (1) {
      int y = sta[top--];
      insta[y] = 0;
      if (y == x) break;
    }
  }
}
void del(int x) {
  if (x == ST) return;
  del(pre[x].first);
  int z = pre[x].second >> 1;
  ans1 = z;
  ans2 = 0;
  use[z] = 0;
  tim = 0;
  for (int i = 1; i <= n; ++i) dfn[i] = 0;
  tarjan(ST, 0);
  if (!dfn[ED]) update();
  use[z] = 1;
}
int main() {
  while (~scanf("%d%d", &n, &m)) {
    for (int i = 1; i <= n; ++i) {
      first[i] = 0;
      vis[i] = 0;
    }
    id = 1;
    scanf("%d%d", &ST, &ED);
    for (int i = 1; i <= m; ++i) {
      int x, y, z;
      scanf("%d%d%d", &x, &y, &z);
      ins(x, y, z);
      ins(y, x, z);
      use[i] = 1;
    }
    dfs(ST);
    if (!vis[ED]) {
      puts("0");
      puts("0");
      puts("");
      continue;
    }
    ans = 2.1e9;
    del(ED);
    if (ans == 2.1e9)
      puts("-1");
    else {
      printf("%d\n", ans);
      printf("%d\n", ANS.size());
      for (int i = 0; i < ANS.size(); ++i) printf("%d ", ANS[i]);
      puts("");
    }
  }
  return 0;
}
