#include <bits/stdc++.h>
using namespace std;
const int maxn = 1005;
const int INF = 2e9 + 5;
const int maxm = 3e4 + 5;
struct Edge {
  int v, id;
  Edge() {}
  Edge(int v, int id) : v(v), id(id) {}
};
vector<Edge> adj[maxn];
bool Free[maxm], Erase[maxm], Bridge[maxm];
int p[maxn], pId[maxn], cost[maxm], number[maxn];
int par[maxn], parId[maxn], low[maxn];
int n, m, s, t, timer = 0;
void FindPath(int u) {
  Free[u] = 1;
  for (int i = 0; i < adj[u].size(); ++i)
    if (!Free[adj[u][i].v]) {
      int v = adj[u][i].v;
      p[v] = u;
      pId[v] = adj[u][i].id;
      FindPath(v);
    }
}
void FindBridge(int u) {
  number[u] = ++timer;
  low[u] = n + 1;
  for (int i = 0; i < adj[u].size(); ++i) {
    int v = adj[u][i].v;
    int id = adj[u][i].id;
    if (Free[id] || Erase[id]) continue;
    Free[id] = 1;
    if (!number[v]) {
      par[v] = u;
      parId[v] = id;
      FindBridge(v);
      if (low[v] > number[u]) Bridge[id] = 1;
      low[u] = min(low[u], low[v]);
    } else
      low[u] = min(low[u], number[v]);
  }
}
int Cal() {
  memset(Bridge, 0, sizeof Bridge);
  memset(Free, 0, sizeof Free);
  memset(par, 0, sizeof par);
  memset(parId, 0, sizeof parId);
  memset(low, 0, sizeof low);
  memset(number, 0, sizeof number);
  timer = 0;
  FindBridge(s);
  if (par[t] == 0) return -1;
  int u = t;
  int c = INF, id = -1;
  while (u != s) {
    if (Bridge[parId[u]] && c > cost[parId[u]]) {
      c = cost[parId[u]];
      id = parId[u];
    }
    u = par[u];
  }
  if (id == -1) return -2;
  return id;
}
int main() {
  scanf("%d%d", &n, &m);
  scanf("%d%d", &s, &t);
  for (int i = 1; i <= m; ++i) {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    cost[i] = w;
    adj[u].push_back(Edge(v, i));
    adj[v].push_back(Edge(u, i));
  }
  FindPath(s);
  if (p[t] == 0) {
    printf("%d\n%d\n", 0, 0);
    return 0;
  }
  int u = t;
  int ans = INF;
  int ans_array[5];
  int a = 0;
  while (u != s) {
    Erase[pId[u]] = 1;
    int i = Cal();
    if (i == -1 && ans > cost[pId[u]]) {
      ans = cost[pId[u]];
      ans_array[1] = pId[u];
      a = 1;
    } else if (i != -2 && ans > cost[pId[u]] + cost[i]) {
      ans = cost[pId[u]] + cost[i];
      ans_array[1] = pId[u];
      ans_array[2] = i;
      a = 2;
    }
    Erase[pId[u]] = 0;
    u = p[u];
  }
  if (ans >= INF)
    puts("-1");
  else {
    printf("%d\n%d\n", ans, a);
    for (int i = 1; i <= a; ++i) printf("%d ", ans_array[i]);
  }
}
