#include <bits/stdc++.h>
using namespace std;
const long long INF = numeric_limits<long long>::max();
inline int pow2(int k) { return 1 << k; }
struct R {
  R(int x, int y, int name, int w) : x(x), y(y), name(name), w(w) {}
  int x, y;
  int name;
  int w;
};
const int N = 1000 + 1;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  scanf("%d %d", &n, &m);
  n++;
  int s, t;
  scanf("%d %d", &s, &t);
  vector<vector<int>> g(n);
  vector<vector<vector<R>>> gg(n, vector<vector<R>>(n));
  vector<R> roads;
  for (int i = 0; i < m; i++) {
    int v1, v2, w;
    scanf("%d %d %d", &v1, &v2, &w);
    if (v1 == v2) continue;
    if (gg[v1][v2].size() == 0) {
      g[v1].push_back(v2);
      g[v2].push_back(v1);
    }
    R r(v1, v2, i + 1, w);
    gg[v1][v2].push_back(r);
    gg[v2][v1].push_back(r);
  }
  {
    vector<int> go(n, 0);
    vector<bool> seen(n, 0);
    int v = s;
    vector<int> par(n, -1);
    seen[v] = true;
    while (1) {
      if (go[v] < g[v].size()) {
        int nxt = go[v]++;
        int newv = g[v][nxt];
        if (par[v] == newv || seen[newv]) {
          continue;
        } else {
          par[newv] = v;
          v = newv;
          seen[v] = true;
        }
      } else {
        int p = par[v];
        if (p == -1) break;
        v = p;
      }
    }
    if (seen[t] == false) {
      printf("0\n0\n");
      return 0;
    } else {
      v = t;
      while (v != s) {
        int p = par[v];
        if (p == -1) break;
        for (auto r : gg[v][p]) roads.push_back(r);
        v = p;
      }
    }
  }
  long long best = INF;
  vector<R> result;
  bool flag = false;
  for (const auto &r : roads) {
    long long payed;
    int x, y;
    if (gg[r.x][r.y].size() == 1) {
      payed = r.w;
      x = r.x;
      y = r.y;
    } else if (!flag) {
      payed = 0;
      x = -1;
      y = -1;
      flag = true;
    } else {
      continue;
    }
    vector<int> go(n, 0);
    vector<int> seen(n, 0);
    vector<int> fup(n);
    int v = s;
    vector<int> par(n, -1);
    int time = 1;
    seen[v] = fup[v] = time++;
    while (1) {
      if (go[v] < g[v].size()) {
        int nxt = go[v]++;
        int newv = g[v][nxt];
        if (par[v] == newv) {
          continue;
        }
        if ((v == x && newv == y) || (v == y && newv == x)) {
          continue;
        }
        if (seen[newv] > 0) {
          fup[v] = min(fup[v], seen[newv]);
        } else {
          par[newv] = v;
          v = newv;
          seen[v] = fup[v] = time++;
        }
      } else {
        int p = par[v];
        if (p == -1) break;
        fup[p] = min(fup[p], fup[v]);
        v = p;
      }
    }
    if (seen[t] == 0) {
      if (payed < best) {
        best = payed;
        if (payed > 0) {
          result = {r};
        } else {
          result = vector<R>(0, R(0, 0, 0, 0));
          break;
        }
      }
    } else {
      v = t;
      while (v != s) {
        int p = par[v];
        if (p == -1) break;
        if (fup[v] > seen[p]) {
          const vector<R> &br = gg[v][p];
          if (br.size() == 2 && payed == 0) {
            long long total = payed;
            for (const auto &r : br) {
              total += r.w;
            }
            if (total < best) {
              best = total;
              result = br;
            }
          } else if (br.size() == 1) {
            long long total = payed + br[0].w;
            if (total < best) {
              best = total;
              result = {br[0]};
              if (payed > 0) result.push_back(r);
            }
          }
        }
        v = p;
      }
    }
  }
  if (m == 0) best = 0;
  if (best == INF) {
    printf("%d\n", -1);
  } else {
    printf("%lld\n", best);
    printf("%d\n", result.size());
    for (const auto &r : result) printf("%d ", r.name);
    printf("\n");
  }
  return 0;
}
