#include <bits/stdc++.h>
using namespace std;
const int MAXN = 30010;
template <class T>
void setmin(T &a, T b) {
  if (a > b) {
    a = b;
  }
}
struct edge {
  int u, v, w;
  edge() {}
  edge(int _u, int _v, int _w) : u(_u), v(_v), w(_w) {}
};
bool eq(edge e1, edge e2) { return e1.u == e2.u && e1.v == e2.v; }
int N, M;
int S, T;
vector<int> adj[MAXN];
edge E[MAXN];
bool vis[MAXN];
pair<int, vector<int> > ans(INT_MAX, {});
int oth(int eid, int x) { return E[eid].u + E[eid].v - x; }
bool comp(int src, int e1, int e2) {
  return pair<int, int>(oth(e1, src), e1) < pair<int, int>(oth(e2, src), e2);
}
void insert(int x, int e) {
  adj[x].push_back(e);
  for (int i = adj[x].size() - 1; i; i--) {
    if (comp(x, adj[x][i], adj[x][i - 1])) {
      swap(adj[x][i], adj[x][i - 1]);
    } else {
      break;
    }
  }
}
bool ismatch(int x, int i) {
  return 0 <= i && i + 1 < adj[x].size() &&
         oth(adj[x][i], x) == oth(adj[x][i + 1], x);
}
bool hasmatch(int x, int i) { return ismatch(x, i - 1) || ismatch(x, i); }
void updans(vector<int> v) {
  assert(v.size() && v.size() <= 2);
  int cst = 0;
  for (int x : v) {
    cst += E[x].w;
  }
  setmin(ans, make_pair(cst, v));
}
int par[MAXN], pare[MAXN];
int num[MAXN], low[MAXN], cnum;
bool obrid[MAXN];
vector<int> etree;
void dfs1(int x) {
  num[x] = low[x] = ++cnum;
  for (int i = 0; i < adj[x].size(); i++) {
    int ei = adj[x][i];
    int t = oth(ei, x);
    if (num[t] == MAXN) {
      etree.push_back(ei);
      par[t] = x;
      pare[t] = ei;
      dfs1(t);
      if (low[t] > num[x] && !hasmatch(x, i)) {
        obrid[ei] = true;
      }
      low[x] = min(low[x], low[t]);
    } else if (t != par[x]) {
      low[x] = min(low[x], low[t]);
    }
  }
}
vector<int> vbrid;
bool ibrid[MAXN];
void dfs2(int x) {
  num[x] = low[x] = ++cnum;
  for (int i = 0; i < adj[x].size(); i++) {
    int ei = adj[x][i];
    int t = oth(ei, x);
    if (num[t] == MAXN) {
      par[t] = x;
      pare[t] = ei;
      dfs2(t);
      if (low[t] > num[x] && !hasmatch(x, i)) {
        vbrid.push_back(ei);
        ibrid[ei] = true;
      }
      low[x] = min(low[x], low[t]);
    } else if (t != par[x]) {
      low[x] = min(low[x], low[t]);
    }
  }
}
int main() {
  scanf("%d %d %d %d", &N, &M, &S, &T);
  for (int i = 1; i <= M; i++) {
    int a, b, w;
    scanf("%d %d %d", &a, &b, &w);
    if (a > b) {
      swap(a, b);
    }
    if (a < b) {
      adj[a].push_back(i);
      adj[b].push_back(i);
    }
    E[i] = edge(a, b, w);
  }
  for (int i = 1; i <= N; i++) {
    sort((adj[i]).begin(), (adj[i]).end(),
         [i](int x, int y) { return comp(i, x, y); });
  }
  cnum = 0;
  for (int i = 1; i <= N; i++) {
    num[i] = low[i] = MAXN;
    par[i] = -1;
  }
  dfs1(S);
  if (num[T] == MAXN) {
    puts("0\n0");
    return 0;
  }
  for (int i = T; i != S; i = par[i]) {
    int e = pare[i];
    if (obrid[e]) {
      updans({e});
    }
  }
  for (int ei : etree) {
    if (obrid[ei]) {
      continue;
    }
    int u = E[ei].u, v = E[ei].v;
    adj[u].erase(find((adj[u]).begin(), (adj[u]).end(), ei));
    adj[v].erase(find((adj[v]).begin(), (adj[v]).end(), ei));
    cnum = 0;
    for (int i = 1; i <= N; i++) {
      num[i] = low[i] = MAXN;
      par[i] = -1;
    }
    dfs2(S);
    for (int i = T; i != S; i = par[i]) {
      int e = pare[i];
      if (ibrid[e]) {
        updans({ei, e});
      }
    }
    for (int x : vbrid) {
      ibrid[x] = false;
    }
    vbrid.clear();
    insert(u, ei);
    insert(v, ei);
  }
  if (ans.first == INT_MAX) {
    puts("-1");
    return 0;
  }
  printf("%d\n%lu\n", ans.first, ans.second.size());
  for (int x : ans.second) {
    printf("%d ", x);
  }
}
