#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 5;
struct edges {
  int to, next;
  long long val;
} edge[60005];
int head[maxn], cnt = 0;
int dfn[maxn], low[maxn], cntx = 1;
bool bridge[60005], del[60005];
int s, t;
vector<int> p, b;
int vis[maxn], flag;
void add(int x, int y, long long v) {
  edge[cnt].to = y;
  edge[cnt].next = head[x];
  edge[cnt].val = v;
  head[x] = cnt++;
}
void tarjan(int x, int in_edge) {
  dfn[x] = low[x] = cntx++;
  for (int i = head[x]; i != -1; i = edge[i].next) {
    if (del[i]) continue;
    int t = edge[i].to;
    if (!dfn[t]) {
      tarjan(t, i);
      low[x] = min(low[x], low[t]);
      if (low[t] > dfn[x]) {
        bridge[i] = bridge[i ^ 1] = true;
        b.push_back(i);
      }
    } else if (i != (in_edge ^ 1))
      low[x] = min(low[x], dfn[t]);
  }
}
void dfs(int x) {
  vis[x] = 1;
  for (int i = head[x]; i != -1; i = edge[i].next) {
    if (del[i]) continue;
    int z = edge[i].to;
    if (vis[z]) continue;
    if (z == t) {
      p.push_back(i);
      flag = 1;
      return;
    }
    dfs(z);
    if (flag) {
      p.push_back(i);
      return;
    }
  }
}
int main() {
  memset(head, -1, sizeof(head));
  int n, m;
  cin >> n >> m >> s >> t;
  for (int i = 1; i <= m; i++) {
    long long x, y, v;
    cin >> x >> y >> v;
    add(x, y, v), add(y, x, v);
  }
  vector<int> tmp;
  flag = 0;
  dfs(s);
  tmp = p;
  p.clear();
  memset(vis, 0, sizeof(vis));
  if (tmp.empty()) {
    cout << 0 << '\n';
    cout << 0 << '\n';
    return 0;
  }
  long long ans = 1e18;
  vector<int> res;
  for (int i = 0; i < tmp.size(); i++) {
    int z1 = tmp[i];
    del[z1] = del[z1 ^ 1] = 1;
    tarjan(s, 0);
    vector<int> tmpx;
    flag = 0;
    dfs(s);
    tmpx = p;
    p.clear();
    if (tmpx.size() == 0) {
      if (ans > edge[z1].val) {
        ans = edge[z1].val;
        res.clear();
        res.push_back(z1 / 2 + 1);
      }
    } else {
      for (int j = 0; j < tmpx.size(); j++) {
        int z2 = tmpx[j];
        if (bridge[z2]) {
          if (ans > edge[z1].val + edge[z2].val) {
            ans = edge[z1].val + edge[z2].val;
            res.clear();
            res.push_back(z1 / 2 + 1);
            res.push_back(z2 / 2 + 1);
          }
        }
      }
    }
    memset(vis, 0, sizeof(vis));
    memset(dfn, 0, sizeof(dfn));
    memset(low, 0, sizeof(low));
    cntx = 1;
    for (int j = 0; j < b.size(); j++) {
      bridge[b[j]] = bridge[b[j] ^ 1] = false;
    }
    b.clear();
    del[z1] = del[z1 ^ 1] = 0;
  }
  if (ans == 1e18)
    cout << -1 << '\n';
  else {
    cout << ans << '\n';
    cout << res.size() << '\n';
    for (int i = 0; i < res.size(); i++) {
      cout << res[i];
      if (i == res.size() - 1)
        cout << '\n';
      else
        cout << ' ';
    }
  }
  return 0;
}
