#include <bits/stdc++.h>
using namespace std;
const int MAXN = 30005;
vector<pair<int, int> > adj[MAXN], tree[MAXN];
bool block[MAXN], vis[MAXN], isBridge[MAXN];
int n, m, s, t, cost[MAXN], cnt[1005][1005], par[MAXN], dfn[MAXN], low[MAXN],
    step;
;
pair<int, int> pt[MAXN];
vector<pair<int, vector<int> > > ans;
vector<int> simple;
int parent[1005];
int find(int u) { return u == parent[u] ? u : parent[u] = find(parent[u]); }
void mrg(int u, int v) {
  u = find(u), v = find(v);
  if (u == v) return;
  parent[u] = v;
}
int tcost, tedge;
bool path_exist(int here, int des, bool need,
                vector<pair<int, int> > adj[MAXN]) {
  bool ret = false;
  vis[here] = 1;
  if (here == des) return ret = true;
  for (int i = 0; i < adj[here].size(); i++) {
    int there = adj[here][i].first;
    int eid = adj[here][i].second;
    if (block[eid] || vis[there]) continue;
    if (path_exist(there, des, need, adj)) {
      if (tcost > cost[eid] && isBridge[eid]) tcost = cost[eid], tedge = eid;
      if (need) simple.push_back(eid);
      return true;
    }
  }
  return false;
}
bool can_s_to_t(int s, int t, bool need, vector<pair<int, int> > adj[MAXN]) {
  memset(vis, 0, sizeof(vis));
  return path_exist(s, t, need, adj);
}
void dfs(int here) {
  ++step;
  dfn[here] = low[here] = step;
  for (int i = 0; i < adj[here].size(); i++) {
    int eid = adj[here][i].second;
    if (block[eid]) continue;
    int there = adj[here][i].first;
    if (!dfn[there]) {
      par[there] = here;
      dfs(there);
      low[here] = min(low[here], low[there]);
      if (low[there] > dfn[here]) isBridge[eid] = 1;
    } else if (par[here] != there)
      low[here] = min(low[here], dfn[there]);
  }
}
void push(int u, int v, int val) {
  cnt[u][v] += val;
  cnt[v][u] += val;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> s >> t;
  for (int i = 1; i <= m; i++) {
    cin >> pt[i].first >> pt[i].second >> cost[i];
    adj[pt[i].first].push_back({pt[i].second, i});
    adj[pt[i].second].push_back({pt[i].first, i});
    cnt[pt[i].second][pt[i].first]++;
    cnt[pt[i].first][pt[i].second]++;
  }
  if (!can_s_to_t(s, t, true, adj)) {
    cout << "0\n0\n";
    exit(0);
  }
  for (auto eid : simple) {
    block[eid] = true;
    push(pt[eid].first, pt[eid].second, -1);
    if (!can_s_to_t(s, t, false, adj)) {
      ans.push_back({cost[eid], {eid}});
      block[eid] = false;
      push(pt[eid].first, pt[eid].second, 1);
      continue;
    }
    step = 0;
    memset(low, 0, sizeof(low));
    memset(dfn, 0, sizeof(dfn));
    memset(isBridge, false, sizeof(isBridge));
    dfs(s);
    for (int i = 1; i <= m; i++) {
      if (cnt[pt[i].first][pt[i].second] > 1) isBridge[i] = false;
    }
    for (int i = 1; i <= n; i++) tree[i].clear(), parent[i] = i;
    for (int i = 1; i <= m; i++) {
      if (!isBridge[i] && !block[i]) mrg(pt[i].first, pt[i].second);
    }
    for (int i = 1; i <= m; i++) {
      if (isBridge[i] && !block[i]) {
        tree[find(pt[i].first)].push_back({find(pt[i].second), i});
        tree[find(pt[i].second)].push_back({find(pt[i].first), i});
      }
    }
    if (find(s) != find(t)) {
      tcost = 2e9;
      tedge = -1;
      can_s_to_t(find(s), find(t), false, tree);
      ans.push_back({cost[eid] + cost[tedge], {eid, tedge}});
    }
    push(pt[eid].first, pt[eid].second, 1);
    block[eid] = false;
  }
  sort(ans.begin(), ans.end());
  if (ans.size() == 0) {
    cout << -1;
    exit(0);
  }
  cout << ans[0].first << "\n";
  cout << ans[0].second.size() << "\n";
  for (auto x : ans[0].second) {
    cout << x << ' ';
  }
  return 0;
}
