#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int MAXN = 1005;
const int MAXM = 30005;
const int INF = (int)2e9 + 7;
struct edge {
  int from;
  int to;
  int w;
  edge() {}
  edge(const int &from, const int &to, const int &w)
      : from(from), to(to), w(w) {}
};
int towns[2];
vector<pair<int, int> > g[MAXN];
edge edges[MAXM];
int bad;
int in_time[MAXN];
int dist[2][MAXN];
int t;
int f[MAXN];
vector<int> bridges;
pair<int, int> p[MAXN];
vector<int> path;
vector<int> road;
int ans;
void dfs1(int v) {
  in_time[v] = 1;
  for (const auto &to : g[v])
    if (in_time[to.first] == 0) dfs1(to.first);
}
void dfs2(int v, int id = -1) {
  f[v] = in_time[v] = ++t;
  for (const auto &to : g[v]) {
    if (to.second == id || to.second == bad) continue;
    if (in_time[to.first] != 0)
      f[v] = min(f[v], in_time[to.first]);
    else {
      dfs2(to.first, to.second);
      f[v] = min(f[v], f[to.first]);
      if (f[to.first] > in_time[v]) bridges.push_back(to.second);
    }
  }
}
void bfs1(int id) {
  fill(dist[id], dist[id] + MAXN, MAXN);
  int s = towns[id];
  dist[id][s] = 0;
  queue<int> que;
  que.push(s);
  while (!que.empty()) {
    int best = que.front();
    que.pop();
    for (const auto &to : g[best]) {
      if (to.second == bad) continue;
      if (dist[id][to.first] > dist[id][best] + 1) {
        dist[id][to.first] = dist[id][best] + 1;
        que.push(to.first);
      }
    }
  }
}
void bfs2() {
  fill(dist[0], dist[0] + MAXN, MAXN);
  int s = towns[0];
  dist[0][s] = 0;
  queue<int> que;
  que.push(s);
  while (!que.empty()) {
    int best = que.front();
    que.pop();
    for (const auto &to : g[best]) {
      if (to.second == bad) continue;
      if (dist[0][to.first] > dist[0][best] + 1) {
        dist[0][to.first] = dist[0][best] + 1;
        p[to.first] = {best, to.second};
        que.push(to.first);
      }
    }
  }
  int v = towns[1];
  while (p[v].first != 0) {
    path.push_back(p[v].second);
    v = p[v].first;
  }
}
bool on_path(int id) {
  int u = edges[id].from;
  int v = edges[id].to;
  return dist[0][u] + dist[1][v] + 1 == dist[0][towns[1]] ||
         dist[1][u] + dist[0][v] + 1 == dist[0][towns[1]];
}
int check_it() {
  bfs1(0);
  bfs1(1);
  memset(in_time, 0, sizeof(in_time));
  t = 0;
  bridges.clear();
  dfs2(towns[0]);
  int res = INF;
  int way = -1;
  for (int i = 0; i < (int)bridges.size(); ++i) {
    int id = bridges[i];
    if (on_path(id) && edges[id].w < res) {
      res = edges[id].w;
      way = id;
    }
  }
  return way;
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  scanf("%d %d", &towns[0], &towns[1]);
  for (int i = 1; i <= m; ++i) {
    int x, y, w;
    scanf("%d %d %d", &x, &y, &w);
    g[x].push_back({y, i});
    g[y].push_back({x, i});
    edges[i] = {x, y, w};
  }
  dfs1(towns[0]);
  if (in_time[towns[1]] == 0) {
    printf("0\n0");
    return 0;
  }
  ans = check_it();
  if (ans != -1) {
    road.push_back(ans);
    ans = edges[ans].w;
  } else
    ans = INF;
  bfs2();
  for (int i = 0; i < (int)path.size(); ++i) {
    int id = path[i];
    bad = id;
    int res = check_it();
    if (res == -1) continue;
    if (edges[res].w + edges[id].w < ans) {
      ans = edges[res].w + edges[id].w;
      road.clear();
      road.push_back(res);
      road.push_back(id);
    }
  }
  if (ans == INF)
    printf("-1");
  else {
    int sz = (int)road.size();
    printf("%d\n%d\n", ans, sz);
    for (int i = 0; i < sz; ++i) printf("%d ", road[i]);
  }
  return 0;
}
