#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000000;
const long long INF = 1LL * inf * inf;
const double eps = 1e-9;
const int MAXN = 2500;
const int md = (int)1e9 + 7;
const double EPS = 1e-5;
const long long maxll = numeric_limits<long long>::max();
template <typename name>
inline name sqr(name x) {
  return x * x;
}
inline long long multmod(long long a, long long b, long long md) {
  if (!a) return 0;
  if (a % 2 == 1)
    return (multmod(a - 1, b, md) + b) % md;
  else
    return sqr<long long>(multmod(a / 2, b, md)) % md;
}
template <typename name>
inline name bpow(name base, long long exp, long long md = maxll) {
  if (exp == 0) return 1;
  if (exp % 2 == 1)
    return (base * bpow(base, exp - 1, md)) % md;
  else {
    name k = bpow(base, exp / 2, md);
    return (k * k) % md;
  }
}
int n, num, timer, m, s, t, tin[30000], fup[30000], use[30000], pred[30000],
    w[100000];
vector<int> way[30000];
long long ans = INF, now;
int pr[200000];
pair<int, int> ok;
queue<int> q;
struct edge {
  int from, to, cost;
  edge(int from_, int to_, int cost_) {
    this->from = from_;
    this->to = to_;
    this->cost = cost_;
  }
  edge() {}
} e[200000];
void dfs(int v, int p, int forbid) {
  use[v] = 1;
  tin[v] = fup[v] = timer++;
  for (size_t i = 0; i < way[v].size(); ++i) {
    int to = way[v][i];
    if (to == forbid) continue;
    if (to == p) continue;
    int x1 = e[to].from, y = e[to].to;
    if (y == v) y = x1;
    if (use[y])
      fup[v] = min(fup[v], tin[y]);
    else {
      dfs(y, to, forbid);
      fup[v] = min(fup[v], fup[y]);
      if (fup[y] > tin[v]) {
        if (e[to].cost < now && w[to])
          now = min(now, 1ll * e[to].cost), num = to;
      }
    }
  }
}
long long get(int forbid) {
  timer = 0;
  num = -1;
  now = INF;
  for (int i = 1; i <= n; i++) use[i] = 0, pr[i] = 0;
  for (int i = 1; i <= m; i++) w[i] = 0;
  q.push(s);
  use[s] = 1;
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int i = 0; i < way[x].size(); i++) {
      if (way[x][i] == forbid) continue;
      int x1 = e[way[x][i]].from, x2 = e[way[x][i]].to, to;
      if (x1 != x)
        to = x1;
      else
        to = x2;
      if (!use[to]) use[to] = 1, q.push(to), pr[to] = way[x][i];
    }
  }
  if (!use[t]) {
    num = -1;
    return e[forbid].cost;
  }
  int pos = t;
  while (pr[pos] != 0) {
    w[pr[pos]] = 1;
    int x = e[pr[pos]].from;
    if (x == pos)
      pos = e[pr[pos]].to;
    else
      pos = x;
  }
  for (int i = 1; i <= n; i++) use[i] = 0;
  dfs(s, -1, forbid);
  if (!use[t]) {
    num = -1;
    return e[forbid].cost;
  } else
    return 0ll + now + e[forbid].cost;
}
int main() {
  scanf("%d%d", &n, &m);
  scanf("%d%d", &s, &t);
  for (int i = 1; i <= m; i++) {
    int x, y, c;
    scanf("%d%d%d", &x, &y, &c);
    e[i] = edge(x, y, c);
    way[x].push_back(i);
    way[y].push_back(i);
  }
  q.push(s);
  use[s] = 1;
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int i = 0; i < way[x].size(); i++) {
      int x1 = e[way[x][i]].from, x2 = e[way[x][i]].to, to;
      if (x1 != x)
        to = x1;
      else
        to = x2;
      if (!use[to]) use[to] = 1, q.push(to), pred[to] = way[x][i];
    }
  }
  if (!use[t]) return cout << 0 << "\n" << 0, 0;
  int pos = t;
  while (pred[pos] != 0) {
    long long x = get(pred[pos]);
    if (ans > x) {
      ans = x;
      ok = make_pair(pred[pos], num);
    }
    x = e[pred[pos]].from;
    if (x == pos)
      pos = e[pred[pos]].to;
    else
      pos = x;
  }
  if (ans >= INF)
    cout << -1;
  else {
    cout << ans << "\n";
    if (ok.second > 0)
      cout << 2 << "\n";
    else
      cout << 1 << '\n';
    cout << ok.first;
    if (ok.second > 0) cout << " " << ok.second;
  }
  return 0;
}
