#include <bits/stdc++.h>
using namespace std;
const int maxm = 30000 + 100, maxn = 1000 + 100, inf = 2e9 + 100;
vector<pair<int, int> > adj[maxn];
int fi[maxm], se[maxm], we[maxm];
pair<int, int> par[maxn];
int dp[maxn], h[maxn];
bool mark[maxn], Mark[maxm];
void dfs(int v) {
  mark[v] = true;
  for (int i = 0; i < adj[v].size(); i++) {
    int u = adj[v][i].first, id = adj[v][i].second;
    if (!mark[u]) {
      par[u] = {v, id};
      dfs(u);
    }
  }
}
void Dfs(int v) {
  mark[v] = true;
  dp[v] = h[v];
  for (int i = 0; i < adj[v].size(); i++) {
    int u = adj[v][i].first, id = adj[v][i].second;
    if (Mark[id]) continue;
    if (!mark[u]) {
      par[u] = {v, id};
      h[u] = h[v] + 1;
      Dfs(u);
      dp[v] = min(dp[v], dp[u]);
    } else if (id != par[v].second)
      dp[v] = min(dp[v], h[u]);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m, s, t;
  cin >> n >> m >> s >> t;
  s--, t--;
  for (int i = 0; i < m; i++) {
    cin >> fi[i] >> se[i] >> we[i];
    fi[i]--, se[i]--;
    adj[fi[i]].push_back({se[i], i});
    adj[se[i]].push_back({fi[i], i});
  }
  par[0] = {-1, -1};
  dfs(s);
  if (!mark[t]) {
    cout << "0\n0\n";
    return 0;
  }
  vector<int> path;
  int v = t;
  while (v != s) {
    path.push_back(par[v].second);
    v = par[v].first;
  }
  int ans = inf;
  vector<int> Ans;
  for (int i = 0; i < path.size(); i++) {
    memset(mark, false, sizeof mark);
    Mark[path[i]] = true;
    Dfs(s);
    Mark[path[i]] = false;
    if (!mark[t] && ans > we[path[i]]) {
      ans = we[path[i]];
      Ans.clear();
      Ans.push_back(path[i]);
    }
    if (!mark[t]) continue;
    vector<int> Path;
    int v = t;
    while (v != s) {
      if (dp[v] == h[v]) Path.push_back(par[v].second);
      v = par[v].first;
    }
    int mini = -1;
    for (int j = 0; j < Path.size(); j++)
      if (mini == -1 || we[Path[j]] < we[mini]) mini = Path[j];
    if (mini == -1) continue;
    if (ans > we[mini] + we[path[i]]) {
      ans = we[mini] + we[path[i]];
      Ans.clear();
      Ans.push_back(mini);
      Ans.push_back(path[i]);
    }
  }
  if (ans == inf) {
    cout << "-1\n";
    return 0;
  }
  cout << ans << '\n' << Ans.size() << '\n';
  for (auto idx : Ans) cout << idx + 1 << ' ';
  cout << '\n';
  return 0;
}
