#include <bits/stdc++.h>
using namespace std;
const int mxn = (int)3e4 + 5;
struct edge {
  int to, cost, id;
};
vector<edge> adj[mxn];
vector<int> path1, path2;
int timer = 0;
int vis[mxn];
int BAAD_ID;
int edgeCost[mxn];
int in[mxn], out[mxn];
int isBridge[mxn];
bool dfs1(int u, int to) {
  vis[u] = 1;
  if (u == to) {
    return true;
  }
  for (auto& v : adj[u]) {
    if (!vis[v.to]) {
      if (dfs1(v.to, to)) {
        path1.push_back(v.id);
        return true;
      }
    }
  }
  return false;
}
bool dfs2(int u, int to, int fromId = -1) {
  vis[u] = 1;
  in[u] = out[u] = timer++;
  bool ret = (u == to);
  for (auto& v : adj[u]) {
    if (BAAD_ID == v.id || v.id == fromId) {
      continue;
    }
    if (vis[v.to]) {
      out[u] = min(out[u], in[v.to]);
    } else {
      bool found = dfs2(v.to, to, v.id);
      isBridge[v.id] = (out[v.to] == in[v.to]);
      out[u] = min(out[u], out[v.to]);
      if (found) {
        path2.push_back(v.id);
        ret = true;
      }
    }
  }
  return ret;
}
void initialization() {
  path2.clear();
  timer = 0;
  memset(vis, 0, sizeof vis);
  memset(isBridge, 0, sizeof isBridge);
}
int main() {
  int n, m, s, t;
  cin >> n >> m >> s >> t;
  --s, --t;
  for (int i = 0; i < m; ++i) {
    int x, y, c;
    cin >> x >> y >> c;
    --x, --y;
    adj[x].push_back(edge{y, c, i});
    adj[y].push_back(edge{x, c, i});
    edgeCost[i] = c;
  }
  dfs1(s, t);
  if (path1.empty()) {
    cout << 0 << endl << 0 << endl;
    return 0;
  }
  vector<int> best;
  int bestCost = INT_MAX;
  for (auto& baad1 : path1) {
    BAAD_ID = baad1;
    initialization();
    if (!dfs2(s, t)) {
      if (bestCost > edgeCost[baad1]) {
        bestCost = edgeCost[baad1];
        best = {baad1};
      }
      continue;
    }
    for (auto& baad2 : path2) {
      if (!isBridge[baad2]) {
        continue;
      }
      if (bestCost > (edgeCost[baad2] + edgeCost[baad1])) {
        bestCost = edgeCost[baad2] + edgeCost[baad1];
        best = {baad1, baad2};
      }
    }
  }
  if (bestCost == INT_MAX) {
    cout << -1 << endl;
    return 0;
  }
  cout << bestCost << endl;
  cout << best.size() << endl;
  for (auto& u : best) {
    cout << u + 1 << " ";
  }
  cout << endl;
  return 0;
}
