#include <bits/stdc++.h>
using namespace std;
const int N = 1000 + 5;
vector<pair<int, int> > ke[N];
vector<pair<int, int> > op[N];
vector<int> vt[N];
int n, m, s, t, low[N], num[N], timer, cha[N], trace[N];
pair<int, int> id[N], ban, id2[N];
int low2[N], num2[N], cha2[N];
int res3, res1, res2;
void dfs(int u) {
  num[u] = ++timer;
  low[u] = num[u];
  for (int j = 0; j < int(ke[u].size()); j++) {
    int v = ke[u][j].first, w = ke[u][j].second;
    if (!cha[v]) {
      cha[v] = u;
      id[v] = pair<int, int>(u, j);
      dfs(v);
      low[u] = min(low[u], low[v]);
    } else if (op[u][j].first != id[u].first || op[u][j].second != id[u].second)
      low[u] = min(low[u], num[v]);
  }
}
void dfs2(int u) {
  low2[u] = ++timer;
  num2[u] = low2[u];
  for (int j = 0; j < int(ke[u].size()); j++)
    if (pair<int, int>(u, j) != ban && op[u][j] != ban) {
      int v = ke[u][j].first, w = ke[u][j].second;
      if (!cha2[v]) {
        cha2[v] = u;
        id2[v] = pair<int, int>(u, j);
        dfs2(v);
        low2[u] = min(low2[u], low2[v]);
      } else if (op[u][j].first != id2[u].first ||
                 op[u][j].second != id2[u].second)
        low2[u] = min(low2[u], num2[v]);
    }
}
int main() {
  cin >> n >> m;
  cin >> s >> t;
  for (int i = 1; i <= m; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    ke[u].push_back(pair<int, int>(v, w));
    ke[v].push_back(pair<int, int>(u, w));
    vt[u].push_back(i);
    vt[v].push_back(i);
    op[u].push_back(pair<int, int>(v, int(ke[v].size()) - 1));
    op[v].push_back(pair<int, int>(u, int(ke[u].size()) - 1));
  }
  cha[s] = s;
  dfs(s);
  int ans = 2e9 + 1;
  if (!cha[t])
    cout << 0 << "\n" << 0;
  else {
    int v = t;
    while (v != s) {
      int u = cha[v];
      int ans1 = ke[id[v].first][id[v].second].second;
      if (low[v] >= num[v]) {
        if (ans > ans1) {
          ans = ans1;
          res3 = 1;
          res1 = vt[id[v].first][id[v].second];
        }
      } else {
        ban = id[v];
        timer = 0;
        memset(cha2, 0, sizeof(cha2));
        cha2[s] = s;
        dfs2(s);
        int vv = t;
        while (vv != s) {
          int uu = cha2[vv];
          int ans2 = ke[id2[vv].first][id2[vv].second].second;
          if (low2[vv] >= num2[vv] && ans > ans1 + ans2) {
            ans = ans1 + ans2;
            res3 = 2;
            res1 = vt[id[v].first][id[v].second];
            res2 = vt[id2[vv].first][id2[vv].second];
          }
          vv = uu;
        }
      }
      v = u;
    }
    if (ans > 2e9)
      cout << -1;
    else {
      cout << ans << "\n" << res3 << "\n" << res1;
      if (res3 == 2) cout << ' ' << res2;
    }
  }
}
