#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void ckmax(T& x, T y) {
  x = (y > x ? y : x);
}
template <typename T>
inline void ckmin(T& x, T y) {
  x = (y < x ? y : x);
}
namespace Fread {
const int SIZE = 1 << 21;
char buf[SIZE], *S, *T;
inline char getchar() {
  if (S == T) {
    T = (S = buf) + fread(buf, 1, SIZE, stdin);
    if (S == T) return '\n';
  }
  return *S++;
}
}  // namespace Fread
namespace Fwrite {
const int SIZE = 1 << 21;
char buf[SIZE], *S = buf, *T = buf + SIZE;
inline void flush() {
  fwrite(buf, 1, S - buf, stdout);
  S = buf;
}
inline void putchar(char c) {
  *S++ = c;
  if (S == T) flush();
}
struct NTR {
  ~NTR() { flush(); }
} ztr;
}  // namespace Fwrite
namespace Fastio {
struct Reader {
  template <typename T>
  Reader& operator>>(T& x) {
    char c = Fread ::getchar();
    T f = 1;
    while (c < '0' || c > '9') {
      if (c == '-') f = -1;
      c = Fread ::getchar();
    }
    x = 0;
    while (c >= '0' && c <= '9') {
      x = x * 10 + (c - '0');
      c = Fread ::getchar();
    }
    x *= f;
    return *this;
  }
  Reader& operator>>(char& c) {
    c = Fread ::getchar();
    while (c == '\n' || c == ' ') c = Fread ::getchar();
    return *this;
  }
  Reader& operator>>(char* str) {
    int len = 0;
    char c = Fread ::getchar();
    while (c == '\n' || c == ' ') c = Fread ::getchar();
    while (c != '\n' && c != ' ') {
      str[len++] = c;
      c = Fread ::getchar();
    }
    str[len] = '\0';
    return *this;
  }
  Reader() {}
} cin;
const char endl = '\n';
struct Writer {
  template <typename T>
  Writer& operator<<(T x) {
    if (x == 0) {
      Fwrite ::putchar('0');
      return *this;
    }
    if (x < 0) {
      Fwrite ::putchar('-');
      x = -x;
    }
    static int sta[45];
    int top = 0;
    while (x) {
      sta[++top] = x % 10;
      x /= 10;
    }
    while (top) {
      Fwrite ::putchar(sta[top] + '0');
      --top;
    }
    return *this;
  }
  Writer& operator<<(char c) {
    Fwrite ::putchar(c);
    return *this;
  }
  Writer& operator<<(char* str) {
    int cur = 0;
    while (str[cur]) Fwrite ::putchar(str[cur++]);
    return *this;
  }
  Writer& operator<<(const char* str) {
    int cur = 0;
    while (str[cur]) Fwrite ::putchar(str[cur++]);
    return *this;
  }
  Writer() {}
} cout;
}  // namespace Fastio
const int MAXN = 1e5, MAXM = 1e5;
const int INF = 2e9 + 233;
int n, m, s, t;
struct EDGE {
  int nxt, to, w, id;
} edge[MAXM * 2 + 5];
int head[MAXN + 5], tot;
inline void add_edge(int u, int v, int w, int id) {
  edge[++tot].nxt = head[u];
  edge[tot].to = v;
  edge[tot].w = w;
  edge[tot].id = id;
  head[u] = tot;
}
vector<int> DfsTree[MAXN + 5];
bool vis[MAXN + 5];
int fa[MAXN + 5], fw[MAXN + 5], fid[MAXN + 5];
unsigned long long f_rand[MAXN + 5];
map<unsigned long long, bool> value_used;
unsigned long long get_rand() {
  unsigned long long res =
      (((unsigned long long)rand() << 30) ^ (rand() << 15) ^ rand());
  while (value_used[res]) {
    res = (((unsigned long long)rand() << 30) ^ (rand() << 15) ^ rand());
  }
  value_used[res] = 1;
  return res;
}
void dfs1(int u) {
  vis[u] = 1;
  for (int i = head[u]; i; i = edge[i].nxt) {
    int v = edge[i].to;
    if (edge[i].id == fid[u]) continue;
    if (!vis[v]) {
      fa[v] = u;
      fw[v] = edge[i].w;
      fid[v] = edge[i].id;
      f_rand[v] = get_rand();
      DfsTree[u].push_back(v);
      dfs1(v);
    }
  }
}
int sz[MAXN + 5], son[MAXN + 5], dep[MAXN + 5];
void dfs2(int u) {
  sz[u] = 1;
  for (int i = 0; i < ((int)(DfsTree[u]).size()); ++i) {
    int v = DfsTree[u][i];
    dep[v] = dep[u] + 1;
    dfs2(v);
    sz[u] += sz[v];
    if (!son[u] || sz[v] > sz[son[u]]) son[u] = v;
  }
}
int top[MAXN + 5], dfn[MAXN + 5], ofn[MAXN + 5], rev[MAXN + 5], cnt_dfn;
void dfs3(int u, int t) {
  top[u] = t;
  dfn[u] = ++cnt_dfn;
  rev[cnt_dfn] = u;
  if (son[u]) dfs3(son[u], t);
  for (int i = 0; i < ((int)(DfsTree[u]).size()); ++i) {
    int v = DfsTree[u][i];
    if (v == son[u]) continue;
    dfs3(v, v);
  }
  ofn[u] = cnt_dfn;
}
int get_lca(int u, int v) {
  while (top[u] != top[v]) {
    if (dep[top[u]] < dep[top[v]]) swap(u, v);
    u = fa[top[u]];
  }
  return (dep[u] < dep[v]) ? u : v;
}
int num[MAXN + 5];
long long sum_w[MAXN + 5], sum_id[MAXN + 5];
unsigned long long sum_hash[MAXN + 5];
int id[MAXN + 5], lca[MAXN + 5];
set<pair<int, int> > S[MAXN + 5];
vector<pair<int, int> > to_del[MAXN + 5];
int deeper_node(int id) {
  int x = edge[id * 2].to;
  int y = edge[id * 2 - 1].to;
  if (dep[x] < dep[y]) swap(x, y);
  return x;
}
void dfs4(int u) {
  vis[u] = 1;
  for (int i = head[u]; i; i = edge[i].nxt) {
    int v = edge[i].to;
    if (edge[i].id == fid[u]) continue;
    if (!vis[v]) {
      dfs4(v);
      num[u] += num[v];
      sum_w[u] += sum_w[v];
      sum_id[u] += sum_id[v];
      sum_hash[u] += sum_hash[v];
      if (((int)(S[id[u]]).size()) < ((int)(S[id[v]]).size())) {
        swap(id[u], id[v]);
      }
      for (set<pair<int, int> >::iterator it = S[id[v]].begin();
           it != S[id[v]].end(); ++it) {
        S[id[u]].insert(*it);
      }
    } else if (dfn[v] < dfn[u]) {
      num[u]++;
      num[v]--;
      sum_w[u] += edge[i].w;
      sum_w[v] -= edge[i].w;
      sum_id[u] += edge[i].id;
      sum_id[v] -= edge[i].id;
      sum_hash[u] += f_rand[u];
      sum_hash[v] -= f_rand[u];
      S[id[u]].insert(make_pair(dfn[u], edge[i].id));
      to_del[v].push_back(make_pair(dfn[u], edge[i].id));
    }
  }
  for (int i = 0; i < ((int)(to_del[u]).size()); ++i) {
    S[id[u]].erase(to_del[u][i]);
  }
  assert(((int)(S[id[u]]).size()) == num[u]);
  if (num[u] >= 1) {
    lca[u] = get_lca(deeper_node(S[id[u]].begin()->second),
                     deeper_node(S[id[u]].rbegin()->second));
  }
}
bool cmp(int x, int y) { return sum_hash[x] < sum_hash[y]; }
struct SegmentTree {
  int mn[MAXN * 4 + 5], mnpos[MAXN * 4 + 5];
  void push_up(int p) {
    if (mn[p << 1] <= mn[p << 1 | 1]) {
      mn[p] = mn[p << 1];
      mnpos[p] = mnpos[p << 1];
    } else {
      mn[p] = mn[p << 1 | 1];
      mnpos[p] = mnpos[p << 1 | 1];
    }
  }
  void build(int p, int l, int r) {
    if (l == r) {
      mn[p] = INF;
      mnpos[p] = l;
      return;
    }
    int mid = (l + r) >> 1;
    build(p << 1, l, mid);
    build(p << 1 | 1, mid + 1, r);
    push_up(p);
  }
  void point_modify(int p, int l, int r, int pos, int v) {
    if (l == r) {
      mn[p] = v;
      return;
    }
    int mid = (l + r) >> 1;
    if (pos <= mid) {
      point_modify(p << 1, l, mid, pos, v);
    } else {
      point_modify(p << 1 | 1, mid + 1, r, pos, v);
    }
    push_up(p);
  }
  pair<int, int> query(int p, int l, int r, int ql, int qr) {
    if (ql <= l && qr >= r) {
      return make_pair(mn[p], mnpos[p]);
    }
    int mid = (l + r) >> 1;
    pair<int, int> res = make_pair(INF, INF);
    if (ql <= mid) {
      res = query(p << 1, l, mid, ql, qr);
    }
    if (qr > mid) {
      ckmin(res, query(p << 1 | 1, mid + 1, r, ql, qr));
    }
    return res;
  }
  SegmentTree() {}
} Segt;
int main() {
  srand((unsigned long long)time(0) ^ (unsigned long long)(new char));
  Fastio ::cin >> n >> m;
  Fastio ::cin >> s >> t;
  for (int i = 1; i <= m; ++i) {
    int u, v, w;
    Fastio ::cin >> u >> v >> w;
    add_edge(u, v, w, i);
    add_edge(v, u, w, i);
  }
  dfs1(s);
  if (!vis[t]) {
    Fastio ::cout << 0 << Fastio ::endl;
    Fastio ::cout << 0 << Fastio ::endl;
    Fastio ::cout << Fastio ::endl;
    return 0;
  }
  dfs2(s);
  dfs3(s, s);
  for (int i = 1; i <= n; ++i) {
    vis[i] = 0;
    id[i] = i;
  }
  dfs4(s);
  pair<int, pair<int, int> > ans = make_pair(INF, make_pair(INF, INF));
  for (int u = t; u != s; u = fa[u]) {
    if (num[u] == 0) {
      ckmin(ans, make_pair(fw[u], make_pair(fid[u], 0)));
    } else if (num[u] == 1) {
      ckmin(ans, make_pair(fw[u] + (int)sum_w[u],
                           make_pair(fid[u], (int)sum_id[u])));
    }
  }
  sort(id + 1, id + n + 1, cmp);
  Segt.build(1, 1, n);
  for (int i = 1; i <= n; ++i) {
    if (!sum_hash[id[i]]) {
      continue;
    }
    int j = i;
    while (j + 1 <= n && sum_hash[id[j + 1]] == sum_hash[id[i]]) {
      ++j;
    }
    for (int k = i; k <= j; ++k) {
      Segt.point_modify(1, 1, n, dfn[id[k]], fw[id[k]]);
    }
    for (int k = i; k <= j; ++k) {
      int u = id[k];
      if (u != s && dfn[u] <= dfn[t] && ofn[u] >= dfn[t]) {
        int y = get_lca(t, lca[u]);
        int v = lca[u];
        while (true) {
          if (v == y) break;
          if (dfn[top[v]] <= dfn[y]) {
            pair<int, int> res = Segt.query(1, 1, n, dfn[y] + 1, dfn[v]);
            if (res.first != INF && res.first + fw[u] < ans.first) {
              ans.first = res.first + fw[u];
              ans.second = make_pair(fid[u], fid[rev[res.second]]);
            }
            break;
          }
          pair<int, int> res = Segt.query(1, 1, n, dfn[top[v]], dfn[v]);
          if (res.first != INF && res.first + fw[u] < ans.first) {
            ans.first = res.first + fw[u];
            ans.second = make_pair(fid[u], fid[rev[res.second]]);
          }
          v = fa[top[v]];
        }
      }
    }
    for (int k = i; k <= j; ++k) {
      Segt.point_modify(1, 1, n, dfn[id[k]], INF);
    }
    i = j;
  }
  if (ans.first == INF) {
    Fastio ::cout << -1 << Fastio ::endl;
    return 0;
  }
  Fastio ::cout << ans.first << Fastio ::endl;
  if (ans.second.second == 0) {
    Fastio ::cout << 1 << Fastio ::endl;
    Fastio ::cout << ans.second.first << Fastio ::endl;
  } else {
    Fastio ::cout << 2 << Fastio ::endl;
    Fastio ::cout << ans.second.first << " " << ans.second.second
                  << Fastio ::endl;
  }
  return 0;
}
