#include <bits/stdc++.h>
using namespace std;
const int nm = 1002;
const int mm = 30002;
const long long inf = 1e18;
struct rec {
  int u, v;
  long long w;
};
int n, m, s, t;
vector<int> adj[nm];
rec edge[mm];
long long d[nm];
int trace[nm];
bool used[mm];
int ii;
int cnt, num[nm], low[nm], par[nm];
int other(int e, int i) { return edge[e].u ^ edge[e].v ^ i; }
void dijkstra() {
  priority_queue<pair<long long, int>> q;
  q.emplace(0, s);
  memset(d, 0x3f, sizeof(d));
  d[s] = 0;
  while (!q.empty()) {
    long long di = -q.top().first;
    int i = q.top().second;
    q.pop();
    if (di != d[i]) {
      continue;
    }
    for (int e : adj[i]) {
      int j = other(e, i);
      if (d[j] > di + edge[e].w) {
        d[j] = di + edge[e].w;
        q.emplace(-d[j], j);
        trace[j] = e;
      }
    }
  }
}
void dfs(int i, int p, int rm) {
  num[i] = low[i] = ++cnt;
  par[i] = p;
  for (int e : adj[i]) {
    if (e == rm || e == p) {
      continue;
    }
    int j = other(e, i);
    if (!num[j]) {
      dfs(j, e, rm);
      low[i] = min(low[i], low[j]);
    } else {
      low[i] = min(low[i], num[j]);
    }
  }
}
long long try_remove(int e) {
  cnt = 0;
  memset(num, 0, sizeof(num));
  dfs(s, -1, e);
  if (!num[t]) {
    ii = -1;
    return edge[e].w;
  }
  long long res = inf;
  int i = t;
  while (i != s) {
    int e = par[i];
    if (low[i] >= num[i]) {
      if (edge[e].w < res) {
        res = edge[e].w;
        ii = e;
      }
    }
    i = other(e, i);
  }
  return res + edge[e].w;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> s >> t;
  for (int i = 1; i <= m; ++i) {
    int u, v;
    long long w;
    cin >> u >> v >> w;
    edge[i] = {u, v, w};
    adj[u].emplace_back(i);
    adj[v].emplace_back(i);
  }
  dijkstra();
  if (d[t] > inf) {
    printf("0\n0\n");
    return 0;
  }
  int i = t;
  while (i != s) {
    int e = trace[i];
    used[e] = 1;
    i = other(e, i);
  }
  long long res = inf;
  int e1, e2;
  for (int i = 1; i <= m; ++i) {
    if (used[i]) {
      long long tmp = try_remove(i);
      if (tmp < res) {
        res = tmp;
        e1 = i;
        e2 = ii;
      }
    }
  }
  if (res == inf) {
    cout << "-1\n";
    return 0;
  }
  cout << res << "\n";
  if (e2 == -1) {
    cout << "1\n" << e1 << "\n";
  } else {
    cout << "2\n" << e1 << " " << e2 << "\n";
  }
}
