#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
using ld = long double;
template <class T>
using Table = vector<vector<T>>;
const ld eps = 1e-9;
struct Edge {
  int src;
  int dst;
  long long int cost;
  int id;
};
int s, t;
vector<vector<Edge>> edges;
int banid;
void dfs(const int now, const int from_id, vector<int>& comes,
         vector<int>& anss) {
  if (comes[now]) return;
  comes[now] = true;
  for (auto e : edges[now]) {
    if (e.id == banid) continue;
    if (e.id == from_id)
      continue;
    else {
      if (e.dst == t) {
        anss = vector<int>(1, e.id);
        return;
      } else {
        dfs(e.dst, e.id, comes, anss);
        if (!anss.empty()) {
          anss.emplace_back(e.id);
          return;
        }
      }
    }
  }
  return;
}
int dfs2(vector<vector<Edge>>& g, vector<int>& res, int v, int& count,
         int from_id, vector<int>& low, vector<int>& pre) {
  pre[v] = count++;
  low[v] = pre[v];
  for (auto it = g[v].begin(); it != g[v].end(); it++) {
    if (it->id == banid) continue;
    int to = it->dst;
    if (pre[to] == -1) {
      low[v] = min(low[v], dfs2(g, res, to, count, it->id, low, pre));
      if (low[to] == pre[to]) {
        res[it->id] = true;
      }
    } else {
      if (from_id == it->id) {
        continue;
      }
      low[v] = min(low[v], low[to]);
    }
  }
  return low[v];
}
void bridges(vector<vector<Edge>>& g, int V, vector<int>& res) {
  if (V > 0) {
    vector<int> low(V, -1);
    vector<int> pre(V, -1);
    int count = 0;
    dfs2(g, res, s, count, -1, low, pre);
  }
}
int main() {
  banid = -1;
  int N, M;
  cin >> N >> M;
  edges.resize(N);
  cin >> s >> t;
  s--;
  t--;
  vector<Edge> eids;
  for (int i = 0; i < M; ++i) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    long long int w;
    cin >> w;
    Edge e{a, b, w, i};
    Edge reve{b, a, w, i};
    edges[a].push_back(e);
    edges[b].push_back(reve);
    eids.push_back(e);
  }
  vector<int> comes(N);
  vector<int> v;
  dfs(s, -1, comes, v);
  sort(v.begin(), v.end(),
       [=](const int l, const int r) { return eids[l].cost < eids[r].cost; });
  long long int ans = 2e9 + 1;
  vector<int> ids;
  if (v.empty()) {
    ans = 0;
  } else {
    for (int i = 0; i < v.size(); ++i) {
      banid = v[i];
      int bancost = eids[banid].cost;
      if (bancost >= ans) continue;
      vector<int> bris(eids.size());
      bridges(edges, N, bris);
      vector<int> acomes(N);
      vector<int> av;
      dfs(s, -1, acomes, av);
      if (av.empty()) {
        const int ncost = bancost;
        if (ans > ncost) {
          ans = ncost;
          ids = vector<int>{banid};
        }
      }
      for (int j = 0; j < av.size(); ++j) {
        if (bris[av[j]]) {
          const int ncost = bancost + eids[av[j]].cost;
          if (ans > ncost) {
            ans = ncost;
            ids = vector<int>{banid, av[j]};
          }
        }
      }
    }
  }
  if (ans == 2e9 + 1) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
    cout << ids.size() << endl;
    for (int i = 0; i < ids.size(); ++i) {
      printf("%d", ids[i] + 1);
      if (i == ids.size() - 1)
        printf("\n");
      else
        printf(" ");
    }
  }
  return 0;
}
