#include <bits/stdc++.h>
using namespace std;
const int MaxN = 1e3;
struct Edge {
  int to, weight, index;
};
int CNT[MaxN][MaxN];
vector<Edge> g[MaxN];
bool used[MaxN];
Edge par[MaxN];
void dfs(int v, int p = -1, int w = -1, int idx = -1) {
  par[v] = {p, w, idx};
  used[v] = true;
  for (int i = 0; i < g[v].size(); ++i) {
    int to = g[v][i].to;
    if (!used[to]) {
      dfs(to, v, g[v][i].weight, g[v][i].index);
    }
  }
}
bool used2[MaxN];
int timer = 0, tin[MaxN], fup[MaxN];
const int MaxM = 30000;
bool bridge[MaxM];
Edge par2[MaxN];
void dfs2(int v, int p = -1, int w = -1, int idx = -1) {
  used2[v] = true;
  par2[v] = {p, w, idx};
  tin[v] = fup[v] = timer++;
  for (size_t i = 0; i < g[v].size(); ++i) {
    int to = g[v][i].to;
    if (to == p) continue;
    if (used2[to])
      fup[v] = min(fup[v], tin[to]);
    else {
      dfs2(to, v, g[v][i].weight, g[v][i].index);
      fup[v] = min(fup[v], fup[to]);
      if (fup[to] > tin[v] && CNT[v][g[v][i].to] == 1)
        bridge[g[v][i].index] = true;
    }
  }
}
void RemoveEdge(int from, int to, int weight, int index) {
  int index1 = 0;
  int index2 = 0;
  for (int i = 0; i < g[from].size(); ++i) {
    if (g[from][i].to == to && g[from][i].index == index &&
        g[from][i].weight == weight) {
      index1 = i;
      break;
    }
  }
  for (int i = 0; i < g[to].size(); ++i) {
    if (g[to][i].to == from && g[to][i].index == index &&
        g[to][i].weight == weight) {
      index2 = i;
      break;
    }
  }
  g[from].erase(g[from].begin() + index1);
  g[to].erase(g[to].begin() + index2);
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int s, t;
  scanf("%d%d", &s, &t);
  --s, --t;
  for (int i = 0; i < m; ++i) {
    int x, y, w;
    scanf("%d%d%d", &x, &y, &w);
    --x, --y;
    CNT[x][y]++;
    CNT[y][x]++;
    g[x].push_back({y, w, i});
    g[y].push_back({x, w, i});
  }
  dfs(s);
  if (!used[t]) {
    cout << "0" << endl << "0" << endl;
    return 0;
  }
  int best_res = 2e9 + 1;
  vector<int> best_ans;
  int cur = t;
  while (cur != s) {
    int prev = par[cur].to;
    int weight = par[cur].weight;
    int idx = par[cur].index;
    CNT[cur][prev]--;
    CNT[prev][cur]--;
    RemoveEdge(cur, prev, weight, idx);
    for (int i = 0; i < n; ++i) {
      used[i] = false;
    }
    dfs(s);
    if (!used[t]) {
      if (weight < best_res) {
        best_res = weight;
        best_ans = {idx};
      }
    } else {
      for (int i = 0; i < m; ++i) bridge[i] = false;
      for (int i = 0; i < n; ++i) used2[i] = false;
      dfs2(s);
      int cur2 = t;
      while (cur2 != s) {
        int prev_idx = par2[cur2].index;
        int weight2 = par2[cur2].weight;
        if (bridge[prev_idx]) {
          if (weight + weight2 < best_res) {
            best_res = weight + weight2;
            best_ans = {idx, prev_idx};
          }
        }
        cur2 = par2[cur2].to;
      }
    }
    g[cur].push_back({prev, weight, idx});
    g[prev].push_back({cur, weight, idx});
    CNT[cur][prev]++;
    CNT[prev][cur]++;
    cur = prev;
  }
  if (best_res == 2e9 + 1) {
    cout << "-1" << endl;
    return 0;
  }
  cout << best_res << endl;
  cout << best_ans.size() << endl;
  for (int i = 0; i < best_ans.size(); ++i) {
    cout << best_ans[i] + 1 << " ";
  }
  cout << endl;
}
