#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INFF = 0x3f3f;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-4;
const long long mod = 1e9 + 7;
const unsigned long long mx = 133333331;
inline void RI(int& x) {
  char c;
  while ((c = getchar()) < '0' || c > '9')
    ;
  x = c - '0';
  while ((c = getchar()) >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0';
}
struct Edge {
  int v, next, c;
} edge[60005];
int head[1005];
int tot;
int s, t;
int vis[1005];
int dfn[1005];
int low[1005];
int bridge[60005];
int Index;
void init() {
  memset(head, -1, sizeof(head));
  memset(vis, 0, sizeof(vis));
  tot = 0;
}
void add_edge(int a, int b, int c) {
  edge[tot] = (Edge){b, head[a], c};
  head[a] = tot++;
}
bool dfs(int u, int fa, int del, vector<int>& path) {
  vis[u] = 1;
  if (u == t) return true;
  for (int i = head[u]; i != -1; i = edge[i].next) {
    int v = edge[i].v;
    if (v == fa || (i >> 1) == del) continue;
    if (!vis[v] && dfs(v, u, del, path)) {
      path.push_back(i >> 1);
      return true;
    }
  }
  return false;
}
void tarjan(int u, int fa, int del) {
  dfn[u] = low[u] = ++Index;
  int flag = 0;
  for (int i = head[u]; i != -1; i = edge[i].next) {
    int v = edge[i].v;
    if ((i >> 1) == del) continue;
    if (v == fa && !flag) {
      flag = 1;
      continue;
    }
    if (!dfn[v]) {
      tarjan(v, u, del);
      low[u] = min(low[v], low[u]);
      if (low[v] > dfn[u]) bridge[i >> 1] = 1;
    } else
      low[u] = min(dfn[v], low[u]);
  }
}
int main() {
  int n, m;
  while (cin >> n >> m) {
    cin >> s >> t;
    init();
    for (int i = 0; i < m; i++) {
      int a, b, c;
      scanf("%d%d%d", &a, &b, &c);
      add_edge(a, b, c);
      add_edge(b, a, c);
    }
    vector<int> path;
    if (!dfs(s, -1, -1, path)) {
      printf("0\n0\n");
    } else {
      int ans = 2e9 + 5;
      vector<int> ret;
      for (int i = 0; i < path.size(); i++) {
        memset(dfn, 0, sizeof(dfn));
        memset(bridge, 0, sizeof(bridge));
        memset(vis, 0, sizeof(vis));
        Index = 0;
        for (int j = 1; j <= n; j++) {
          if (!dfn[j]) tarjan(j, -1, path[i]);
        }
        vector<int> tmp;
        if (!dfs(s, -1, path[i], tmp)) {
          if (ans > edge[path[i] * 2].c) {
            ans = edge[path[i] * 2].c;
            ret.clear();
            ret.push_back(path[i] + 1);
          }
        } else {
          for (int j = 0; j < tmp.size(); j++) {
            if (bridge[tmp[j]]) {
              if (ans > edge[path[i] * 2].c + edge[tmp[j] * 2].c) {
                ans = edge[path[i] * 2].c + edge[tmp[j] * 2].c;
                ret.clear();
                ret.push_back(path[i] + 1);
                ret.push_back(tmp[j] + 1);
              }
            }
          }
        }
      }
      if (ans > 2e9)
        cout << -1 << endl;
      else {
        cout << ans << endl << ret.size() << endl;
        for (int i = 0; i < ret.size(); i++) {
          printf("%d", ret[i]);
          if (i == ret.size() - 1)
            cout << endl;
          else
            cout << " ";
        }
      }
    }
  }
  return 0;
}
