#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int INF = 2e9;
const long long INF64 = 1e18;
const double EPS = 1e-9;
const double PI = acos(-1);
const long long MD = 1551513443;
const long long T = 25923;
const int N = 30010;
const int M = 1002;
const bool DEBUG = 0;
struct Edge {
  int v, u, w;
} e[N];
int n, m, s, t, ans = INF + 1, e_ind, tin[N], up[N], timer, mini, ind;
vector<pair<int, int> > g[N];
vector<int> a, ar;
bool mark[N];
void dfs1(int v) {
  mark[v] = 1;
  for (pair<int, int> u : g[v]) {
    if (!mark[u.first]) {
      a.push_back(u.second);
      dfs1(u.first);
    }
  }
}
bool dfs(int v, int p) {
  if (DEBUG) cout << "====  " << v << endl;
  tin[v] = up[v] = timer++;
  mark[v] = 1;
  bool f = 0;
  for (pair<int, int> u : g[v])
    if (u.second != e_ind && u.second != p) {
      if (mark[u.first])
        up[v] = min(up[v], tin[u.first]);
      else {
        bool q = dfs(u.first, u.second);
        up[v] = min(up[v], up[u.first]);
        if (q && up[u.first] > tin[v] && mini > e[u.second].w) {
          mini = e[u.second].w;
          ind = u.second;
        }
        f |= q;
      }
    }
  if (v == t) f = 1;
  return f;
}
int main() {
  cin >> n >> m >> s >> t;
  for (int i = 0; i < int(m); i++) {
    cin >> e[i].v >> e[i].u >> e[i].w;
    g[e[i].v].push_back(make_pair(e[i].u, i));
    g[e[i].u].push_back(make_pair(e[i].v, i));
  }
  dfs1(s);
  if (!mark[t]) {
    cout << 0 << endl << 0 << endl;
    return 0;
  }
  for (int i : a) {
    e_ind = i;
    if (DEBUG) e_ind = 1;
    fill(mark, mark + N, 0);
    fill(tin, tin + N, 0);
    fill(up, up + N, 0);
    timer = 0;
    mini = INF, ind = -1;
    dfs(s, -1);
    if (ind != -1 && ans > mini + e[e_ind].w) {
      ans = mini + e[e_ind].w;
      ar.clear();
      ar.push_back(e_ind + 1);
      ar.push_back(ind + 1);
    }
    if (!mark[t] && ans > e[e_ind].w) {
      ans = e[e_ind].w;
      ar.clear();
      ar.push_back(e_ind + 1);
    }
    if (DEBUG) break;
  }
  if (ans == INF + 1)
    cout << -1;
  else {
    cout << ans << endl << int((ar).size()) << endl;
    for (int v : ar) cout << v << ' ';
  }
  return 0;
}
