#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
const int M = 1e5 + 10;
int n, m, s, t;
struct E {
  int u, v, w;
} e[M];
struct G {
  struct E {
    int v, w, id, next;
  } e[M];
  int le, head[M];
  void init(int n) {
    le = 0;
    for (int i = 0; i <= n; i++) head[i] = -1;
  }
  void add(int u, int v, int w, int id) {
    e[le].v = v;
    e[le].w = w;
    e[le].id = id;
    e[le].next = head[u];
    head[u] = le++;
  }
} g;
struct A {
  int sum;
  vector<int> id;
  void init() {
    sum = -1;
    id.clear();
  }
  void update(int tsum, int id1, int id2) {
    if (sum == -1 || tsum < sum) {
      sum = tsum;
      id.clear();
      if (~id1) id.push_back(id1);
      if (~id2) id.push_back(id2);
    }
  }
} answer;
class Tarjan_U {
  typedef int typec;
  static const int ME = 1e5 + 10;
  static const int MV = 1e3 + 10;
  int n, Bcnt, Index, num[MV], dfn[MV], low[MV], belong[MV];
  stack<int> s;
  void addqiao(int u, int v, typec w) {
    now.u = u;
    now.v = v;
    now.w = w;
    qiao.push_back(now);
  }
  void tarjan(int u) {
    s.push(u);
    dfn[u] = low[u] = ++Index;
    int v;
    for (int i = g.head[u]; ~i; i = g.e[i].next) {
      if (g.e[i].vis) continue;
      g.e[i].vis = g.e[i ^ 1].vis = true;
      v = g.e[i].v;
      if (!dfn[v]) {
        tarjan(v);
        low[u] = min(low[u], low[v]);
        if (dfn[u] < low[v]) {
          addqiao(u, v, g.e[i].w);
          isbridge[g.e[i].id] = true;
        }
        continue;
      }
      low[u] = min(low[u], dfn[v]);
    }
    if (dfn[u] != low[u]) return;
    Bcnt++;
    do {
      v = s.top();
      s.pop();
      belong[v] = Bcnt;
      num[Bcnt]++;
    } while (v != u);
  }
  struct G {
    struct E {
      int id;
      int v, next;
      bool vis;
      typec w;
    } e[ME];
    int le, head[MV];
    void init(int n) {
      le = 0;
      for (int i = 0; i <= n; i++) head[i] = -1;
    }
    void add(int u, int v, typec w, int id) {
      e[le].vis = false;
      e[le].v = v;
      e[le].w = w;
      e[le].id = id;
      e[le].next = head[u];
      head[u] = le++;
    }
  } g;
  struct Q {
    int u, v;
    typec w;
  } now;
  vector<Q> qiao;
  bool isbridge[ME];

 public:
  bool is_bridge(int id) { return isbridge[id]; }
  void init(int tn) {
    n = tn;
    g.init(n);
  }
  void add(int u, int v, typec w, int id) {
    g.add(u, v, w, id);
    g.add(v, u, w, id);
  }
  void solve() {
    Index = Bcnt = 0;
    for (int i = 1; i <= n; i++) {
      num[i] = dfn[i] = low[i] = 0;
    }
    for (int i = 0; i < m; i++) {
      isbridge[i] = false;
    }
    qiao.clear();
    while (!s.empty()) s.pop();
    for (int i = 1; i <= n; i++) {
      if (!dfn[i]) {
        tarjan(i);
      }
    }
  }
  int getbcnt() { return Bcnt; }
  int getbelong(int id) { return belong[id]; }
  int getnum(int id) { return num[id]; }
} tarjan;
bool tabu[M];
int pre[M];
vector<int> EID, EID2;
bool dfs(int u, int deleteID) {
  tabu[u] = true;
  if (u == t) return true;
  for (int i = g.head[u]; ~i; i = g.e[i].next) {
    int id = g.e[i].id;
    if (id == deleteID) continue;
    int v = g.e[i].v;
    if (tabu[v]) continue;
    pre[v] = u;
    bool flag = dfs(v, deleteID);
    if (flag) return true;
  }
  return false;
}
bool check_c(int deleteID) {
  for (int i = 1; i <= n; i++) {
    tabu[i] = false;
  }
  return dfs(s, deleteID);
}
void get_edge(vector<int> &a, int deleteID) {
  a.clear();
  int u = t;
  while (u != s) {
    for (int i = g.head[u]; ~i; i = g.e[i].next) {
      int id = g.e[i].id;
      if (id == deleteID) continue;
      int v = g.e[i].v;
      if (v != pre[u]) continue;
      a.push_back(g.e[i].id);
      u = v;
      break;
    }
  }
}
void Delete(int deleteID) {
  bool flag = check_c(deleteID);
  if (!flag) {
    answer.update(e[deleteID].w, deleteID, -1);
    return;
  }
  tarjan.init(n);
  for (int i = 0; i < m; i++) {
    if (i == deleteID) continue;
    tarjan.add(e[i].u, e[i].v, e[i].w, i);
  }
  tarjan.solve();
  if (tarjan.getbelong(s) == tarjan.getbelong(t)) return;
  get_edge(EID2, deleteID);
  for (int i = 0; i < EID2.size(); i++) {
    int id = EID2[i];
    if (!tarjan.is_bridge(id)) continue;
    answer.update(e[deleteID].w + e[id].w, deleteID, id);
  }
}
void solve() {
  answer.init();
  g.init(n);
  for (int i = 0; i < m; i++) {
    g.add(e[i].u, e[i].v, e[i].w, i);
    g.add(e[i].v, e[i].u, e[i].w, i);
  }
  bool flag = check_c(-1);
  if (!flag) {
    answer.update(0, -1, -1);
    return;
  }
  get_edge(EID, -1);
  for (int i = 0; i < EID.size(); i++) {
    Delete(EID[i]);
  }
}
int main() {
  while (~scanf("%d%d%d%d", &n, &m, &s, &t)) {
    for (int i = 0; i < m; i++) {
      scanf("%d%d%d", &e[i].u, &e[i].v, &e[i].w);
    }
    solve();
    int sum = answer.sum;
    printf("%d\n", sum);
    if (sum == -1) continue;
    printf("%d\n", answer.id.size());
    for (int i = 0; i < answer.id.size(); i++) {
      printf("%d%c", answer.id[i] + 1, i == answer.id.size() - 1 ? '\n' : ' ');
    }
  }
  return 0;
}
