#include <bits/stdc++.h>
using namespace std;
const long long int inf = 1707050917070509, maxn = 1002;
int n, m, ctr = 0;
vector<int> vis2;
int dfs_low[maxn], dfs_num[maxn], P[maxn], vis[maxn];
vector<int> indi[maxn][maxn];
long long int graph[maxn][maxn];
void dfs(int node, int par) {
  P[node] = par;
  vis[node] = 1;
  dfs_low[node] = dfs_num[node] = ctr++;
  for (int i = 0; i < n; i++) {
    if (i != node && graph[node][i]) {
      if (!vis[i]) {
        dfs(i, node);
        dfs_low[node] = min(dfs_low[node], dfs_low[i]);
      } else if (i != par) {
        dfs_low[node] = min(dfs_low[node], dfs_num[i]);
      }
    }
  }
}
void dfs2(int node, int par, int u, int v) {
  vis2[node] = 1;
  P[node] = par;
  dfs_low[node] = dfs_num[node] = ctr++;
  for (int i = 0; i < n; i++) {
    if (i != node && make_pair(min(node, i), max(node, i)) != make_pair(u, v) &&
        graph[node][i]) {
      if (!vis2[i]) {
        dfs2(i, node, u, v);
        dfs_low[node] = min(dfs_low[node], dfs_low[i]);
      } else if (i != par)
        dfs_low[node] = min(dfs_low[node], dfs_num[i]);
    }
  }
}
int main(void) {
  int s, t, u, v, c;
  scanf("%d%d%d%d", &n, &m, &s, &t);
  vis2.clear();
  vis2.resize(n);
  s--;
  t--;
  for (int i = 0; i < m; i++) {
    scanf("%d%d%d", &u, &v, &c);
    u--;
    v--;
    graph[u][v] += c;
    graph[v][u] += c;
    indi[u][v].push_back(i);
    indi[v][u].push_back(i);
  }
  ctr = 1;
  dfs(s, -1);
  if (!vis[t]) {
    printf("0\n0\n");
    return 0;
  }
  int cur = t;
  pair<long long int, vector<int>> res;
  res.first = inf;
  vector<pair<int, int>> tocheck;
  while (cur != s) {
    if (int(indi[P[cur]][cur].size()) < 3) {
      if (dfs_num[P[cur]] < dfs_low[cur]) {
        res = min(res, {graph[P[cur]][cur], indi[P[cur]][cur]});
      }
    }
    tocheck.push_back({P[cur], cur});
    cur = P[cur];
  }
  for (auto it : tocheck) {
    if (int(indi[it.first][it.second].size()) == 1) {
      vis2.clear();
      vis2.resize(n);
      ctr = 1;
      dfs2(s, -1, min(it.first, it.second), max(it.first, it.second));
      if (!vis2[t]) continue;
      pair<long long int, vector<int>> tmp;
      tmp.first = inf;
      int cur = t;
      while (cur != s) {
        if (int(indi[P[cur]][cur].size()) == 1) {
          if (dfs_num[P[cur]] < dfs_low[cur]) {
            tmp = min(tmp, {graph[P[cur]][cur], indi[P[cur]][cur]});
          }
        }
        cur = P[cur];
      }
      tmp.first += graph[it.first][it.second];
      tmp.second.push_back(indi[it.first][it.second][0]);
      res = min(res, tmp);
    }
  }
  if (res.first >= inf) {
    printf("-1\n");
    return 0;
  }
  printf("%lld\n%d\n", res.first, int(res.second.size()));
  for (auto it : res.second) printf("%d ", it + 1);
  printf("\n");
}
