#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5;
vector<pair<int, int> > adj[MAXN];
pair<int, int> edge[MAXN];
int cost[MAXN], n, m, s, t, low[MAXN], dfn[MAXN], vis[MAXN],
    id = 0, ban[MAXN], par[MAXN], bg[MAXN];
vector<int> path;
int cnt[1005][1005];
void push(int u, int v, int val) {
  cnt[u][v] += val;
  cnt[v][u] += val;
}
bool getSimplePath(int here, vector<int> &path) {
  vis[here] = 1;
  if (here == t) {
    return true;
  }
  for (int i = 0; i < adj[here].size(); i++) {
    int there = adj[here][i].first;
    if (vis[there]) continue;
    int eid = adj[here][i].second;
    if (ban[eid]) continue;
    int f = getSimplePath(there, path);
    if (f) {
      path.push_back(eid);
      return true;
    }
  }
  return false;
}
void init(int pos) {
  id = 0;
  memset(dfn, 0, sizeof(dfn));
  memset(low, 0, sizeof(low));
  memset(ban, 0, sizeof(ban));
  memset(vis, 0, sizeof(vis));
  memset(par, 0, sizeof(par));
  memset(bg, 0, sizeof(bg));
  ban[pos] = 1;
}
long long ans = 2e18;
int A;
void dfs(int here) {
  ++id;
  low[here] = dfn[here] = id;
  for (int i = 0; i < adj[here].size(); i++) {
    int there = adj[here][i].first;
    int eid = adj[here][i].second;
    if (ban[eid]) continue;
    if (!dfn[there]) {
      par[there] = here;
      dfs(there);
      low[here] = min(low[here], low[there]);
      if (low[there] > dfn[here] && cnt[here][there] < 2) {
        bg[eid] = 1;
      }
    } else if (par[here] != there) {
      low[here] = min(low[here], dfn[there]);
    }
  }
}
int anssize = -1;
vector<int> pick;
void process() {
  for (auto eid : path) {
    push(edge[eid].first, edge[eid].second, -1);
    long long cand = 0;
    vector<int> tempPick;
    init(eid);
    cand += cost[eid];
    vector<int> temp;
    getSimplePath(s, temp);
    tempPick.push_back(eid);
    int a = eid;
    if (temp.size() == 0) {
      if (cand < ans) {
        pick = tempPick;
        ans = cand;
        anssize = 1;
      }
      push(edge[eid].first, edge[eid].second, 1);
      continue;
    }
    memset(vis, 0, sizeof(vis));
    A = eid;
    dfs(s);
    int idx = -1;
    int A = 2e9;
    for (auto eid : temp) {
      if (bg[eid] && A > cost[eid]) {
        idx = eid;
        A = cost[eid];
      }
    }
    if (idx == -1) {
      push(edge[eid].first, edge[eid].second, 1);
      continue;
    }
    memset(vis, 0, sizeof(vis));
    ban[idx] = 1;
    vector<int> last;
    getSimplePath(s, last);
    if (last.size() == 0) {
      if (cand + cost[idx] < ans) {
        tempPick.push_back(idx);
        pick = tempPick;
        ans = cand + cost[idx];
        anssize = 2;
      }
    }
    push(edge[eid].first, edge[eid].second, 1);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> s >> t;
  for (int i = 1; i <= m; i++) {
    cin >> edge[i].first >> edge[i].second >> cost[i];
    push(edge[i].first, edge[i].second, 1);
    adj[edge[i].first].push_back(make_pair(edge[i].second, i));
    adj[edge[i].second].push_back(make_pair(edge[i].first, i));
  }
  getSimplePath(s, path);
  for (int i = 0; i < path.size(); i++) {
    int eid = path[i];
  }
  if (path.size() == 0) {
    cout << 0 << endl << 0;
    exit(0);
  }
  process();
  if (ans == 2e18) {
    cout << -1;
    exit(0);
  }
  cout << ans << "\n";
  cout << pick.size() << "\n";
  for (auto x : pick) {
    cout << x << ' ';
  }
  return 0;
}
