#include <bits/stdc++.h>
using namespace std;
const long double pi = 3.1415926535897932384626433832795l;
template <typename T>
inline auto sqr(T x) -> decltype(x * x) {
  return x * x;
}
template <typename T>
inline T abs(T x) {
  return x > T() ? x : -x;
}
template <typename T1, typename T2>
inline bool umx(T1& a, T2 b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T1, typename T2>
inline bool umn(T1& a, T2 b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
const int N = 1010;
const int M = 30100;
const long long inf = (1ll << 31);
int n, m;
int st, fn;
pair<int, int> e[M];
int cost[M];
vector<int> a[N];
vector<int> first_path;
bool use[N];
bool bad[M];
bool dfs(int v, vector<int>& path) {
  if (v == fn) {
    return true;
  }
  use[v] = 1;
  for (auto idx : a[v]) {
    if (bad[idx]) {
      continue;
    }
    int to = e[idx].first + e[idx].second - v;
    if (use[to]) {
      continue;
    }
    if (dfs(to, path)) {
      path.push_back(idx);
      return true;
    }
  }
  return false;
}
bool bridge[M];
int tin[N];
int fup[N];
int tim;
void find_bridges(int v, int pr) {
  use[v] = 1;
  tin[v] = fup[v] = tim++;
  for (auto e_idx : a[v]) {
    if (bad[e_idx] || pr == e_idx) {
      continue;
    }
    int to = e[e_idx].first + e[e_idx].second - v;
    if (use[to]) {
      umn(fup[v], tin[to]);
      continue;
    }
    find_bridges(to, e_idx);
    if (fup[to] > tin[v]) {
      bridge[e_idx] = true;
    }
    umn(fup[v], fup[to]);
  }
}
int calc() {
  memset(bridge, 0, sizeof(bridge));
  memset(use, 0, sizeof(use));
  tim = 0;
  find_bridges(st, -1);
  memset(use, 0, sizeof(use));
  vector<int> second_path;
  if (!dfs(st, second_path)) {
    return -2;
  }
  long long minn = inf;
  int min_idx = -1;
  for (auto e_idx : second_path) {
    if (bridge[e_idx]) {
      if (umn(minn, cost[e_idx])) {
        min_idx = e_idx;
      }
    }
  }
  return min_idx;
}
int main() {
  cout.setf(ios::showpoint | ios::fixed);
  cout.precision(20);
  cin >> n >> m >> st >> fn;
  --st, --fn;
  for (int i = int(0); i < int(m); ++i) {
    cin >> e[i].first >> e[i].second >> cost[i];
    --e[i].first, --e[i].second;
    a[e[i].first].push_back(i);
    a[e[i].second].push_back(i);
  }
  vector<int> first_path;
  memset(bad, 0, sizeof(bad));
  memset(use, 0, sizeof(use));
  if (!dfs(st, first_path)) {
    cout << 0 << endl;
    cout << 0 << endl;
    return 0;
  }
  long long minn = inf;
  vector<int> ans;
  for (auto edge_to_delete : first_path) {
    bad[edge_to_delete] = true;
    int res = calc();
    if (res == -2) {
      if (umn(minn, cost[edge_to_delete])) {
        ans = {edge_to_delete};
      }
    } else if (res >= 0) {
      if (umn(minn, cost[edge_to_delete] + cost[res])) {
        ans = {edge_to_delete, res};
      }
    }
    bad[edge_to_delete] = false;
  }
  if (minn == inf) {
    cout << -1 << endl;
    return 0;
  }
  cout << minn << endl;
  cout << ((int)(ans).size()) << endl;
  for (int i = int(0); i < int(((int)(ans).size())); ++i) {
    cout << ans[i] + 1 << ' ';
  }
  cout << endl;
  return 0;
}
