#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1005;
const int MAXM = 30005 * 2;
struct Edge {
  int to, next, va;
} edge[MAXM];
int head[MAXN], tot = 0;
int Low[MAXN], DFN[MAXN], vis[MAXN] = {0}, bridge[MAXM] = {0};
int Index = 0, n, m, s, t, a, b, c;
void addedge(int u, int v, int c) {
  edge[tot].to = v;
  edge[tot].next = head[u];
  edge[tot].va = c;
  head[u] = tot++;
}
bool dfs(int u, int fa, int del, vector<int> &path) {
  vis[u] = 1;
  if (u == t) {
    return true;
  }
  for (int i = head[u]; ~i; i = edge[i].next) {
    int v = edge[i].to;
    if (v == fa || (i >> 1) == del) {
      continue;
    }
    if (!vis[v] && dfs(v, u, del, path)) {
      path.push_back(i >> 1);
      return true;
    }
  }
  return false;
}
void Tarjan(int u, int fa, int del) {
  DFN[u] = Low[u] = ++Index;
  int flag = 0;
  for (int i = head[u]; i != -1; i = edge[i].next) {
    int v = edge[i].to;
    if ((i >> 1) == del) continue;
    if (v == fa && !flag) {
      flag = 1;
      continue;
    }
    if (!DFN[v]) {
      Tarjan(v, u, del);
      if (Low[u] > Low[v]) Low[u] = Low[v];
      if (Low[v] > DFN[u]) bridge[i >> 1] = 1;
    } else
      Low[u] = min(DFN[v], Low[u]);
  }
}
void init() {
  memset(DFN, 0, sizeof(DFN));
  memset(vis, 0, sizeof(vis));
  memset(bridge, 0, sizeof(bridge));
  Index = 0;
}
int main() {
  memset(head, -1, sizeof(head));
  memset(vis, 0, sizeof(vis));
  scanf("%d%d", &n, &m);
  scanf("%d%d", &s, &t);
  for (int i = 0; i < m; i++) {
    scanf("%d%d%d", &a, &b, &c);
    addedge(a, b, c);
    addedge(b, a, c);
  }
  vector<int> path;
  if (!dfs(s, -1, -1, path)) {
    printf("0\n0\n");
  } else {
    int ans = 2e9 + 5;
    vector<int> ret;
    for (int i = 0; i < path.size(); i++) {
      init();
      for (int j = 1; j <= n; j++) {
        if (!DFN[j]) {
          Tarjan(j, -1, path[i]);
        }
      }
      vector<int> tmp;
      if (!dfs(s, -1, path[i], tmp)) {
        if (ans > edge[path[i] * 2].va) {
          ans = edge[path[i] * 2].va;
          ret.clear();
          ret.push_back(path[i] + 1);
        }
      } else {
        for (int j = 0; j < tmp.size(); j++) {
          if (bridge[tmp[j]]) {
            if (ans > edge[path[i] * 2].va + edge[tmp[j] * 2].va) {
              ans = edge[path[i] * 2].va + edge[tmp[j] * 2].va;
              ret.clear();
              ret.push_back(path[i] + 1);
              ret.push_back(tmp[j] + 1);
            }
          }
        }
      }
    }
    if (ans > 2e9)
      cout << -1 << endl;
    else {
      cout << ans << endl << ret.size() << endl;
      for (int i = 0; i < ret.size(); i++) {
        printf("%d", ret[i]);
        if (i == ret.size() - 1)
          cout << endl;
        else
          cout << " ";
      }
    }
  }
}
