#include <bits/stdc++.h>
using namespace std;
void PR(vector<int>& v) {
  for (auto& x : v) cout << x << ' ';
  cout << endl;
}
const long long inf = 1LL << 60;
const long long inf2 = 2000000003;
struct UF {
  vector<int> e;
  UF(int n) : e(n, -1) {}
  bool same_set(int a, int b) { return find(a) == find(b); }
  int size(int x) { return -e[find(x)]; }
  void join(int a, int b) {
    a = find(a), b = find(b);
    if (a == b) return;
    if (e[a] > e[b]) swap(a, b);
    e[a] += e[b];
    e[b] = a;
  }
  int find(int x) {
    if (e[x] < 0) return x;
    return e[x] = find(e[x]);
  }
};
struct Edge {
  int j;
  int ind;
  long long w;
};
struct Node {
  int time = -10;
  int epar = -10;
  int lo = -10;
  bool seen = false;
};
vector<Node> nodes;
vector<vector<Edge>> ed;
bool dfs(int at, int epar, int& time) {
  Node& n = nodes[at];
  if (n.seen) return false;
  n.seen = 1;
  n.epar = epar;
  n.time = time++;
  n.lo = n.time;
  for (auto& e : ed[at]) {
    int x = e.j;
    if (e.ind == epar) continue;
    bool c = dfs(x, e.ind, time);
    if (c)
      n.lo = min(n.lo, nodes[x].lo);
    else
      n.lo = min(n.lo, nodes[x].time);
  }
  return true;
}
bool is_bridge(int a, Edge e) {
  Node& n = nodes[e.j];
  if (n.epar != e.ind) return false;
  if (n.lo != n.time) return false;
  return true;
}
struct Edge2 {
  int dest, back;
  long long f, c;
  int id;
};
struct PushRelabel {
  vector<vector<Edge2>> g;
  vector<long long> exc;
  vector<Edge2*> cur;
  vector<vector<int>> hs;
  vector<int> H;
  PushRelabel(int n) : g(n), exc(n), cur(n), hs(2 * n), H(n) {}
  void add_edge(int s, int t, int id, long long cap, long long rcap = 0) {
    if (s == t) return;
    Edge2 a = {t, (int)(g[t]).size(), 0, cap, id};
    Edge2 b = {s, (int)(g[s]).size(), 0, rcap, id};
    g[s].push_back(a);
    g[t].push_back(b);
  }
  void add_flow(Edge2& e, long long f) {
    Edge2& back = g[e.dest][e.back];
    if (!exc[e.dest] && f) hs[H[e.dest]].push_back(e.dest);
    e.f += f;
    e.c -= f;
    exc[e.dest] += f;
    back.f -= f;
    back.c += f;
    exc[back.dest] -= f;
  }
  long long maxflow(int s, int t) {
    int v = (int)(g).size();
    H[s] = v;
    exc[t] = 1;
    vector<int> co(2 * v);
    co[0] = v - 1;
    for (int i = 0; i < (v); ++i) cur[i] = g[i].data();
    for (auto& e : g[s]) add_flow(e, e.c);
    for (int hi = 0;;) {
      while (hs[hi].empty())
        if (!hi--) return -exc[s];
      int u = hs[hi].back();
      hs[hi].pop_back();
      while (exc[u] > 0)
        if (cur[u] == g[u].data() + (int)(g[u]).size()) {
          H[u] = 1e9;
          for (auto& e : g[u])
            if (e.c && H[u] > H[e.dest] + 1) H[u] = H[e.dest] + 1, cur[u] = &e;
          if (++co[H[u]], !--co[hi] && hi < v)
            for (int i = 0; i < (v); ++i)
              if (hi < H[i] && H[i] < v) --co[H[i]], H[i] = v + 1;
          hi = H[u];
        } else if (cur[u]->c && H[u] == H[cur[u]->dest] + 1)
          add_flow(*cur[u], min(exc[u], cur[u]->c));
        else
          ++cur[u];
    }
  }
};
void dfs3(vector<vector<Edge2>>& gr, vector<int>& seen, int at, long long& res,
          vector<int>& resv) {
  if (seen[at]++) return;
  for (auto& e : gr[at]) {
    if (e.c > 0) {
      dfs3(gr, seen, e.dest, res, resv);
    }
  }
}
int main() {
  cin.sync_with_stdio(false);
  cin.exceptions(cin.failbit);
  int N, M;
  cin >> N >> M;
  int S, T;
  cin >> S >> T;
  --S, --T;
  UF uf(N);
  ed.resize(N);
  for (int i = 0; i < (M); ++i) {
    int a, b;
    long long w;
    cin >> a >> b >> w;
    --a, --b;
    if (a == b) continue;
    uf.join(a, b);
    ed[a].push_back({b, i + 1, w});
    ed[b].push_back({a, i + 1, w});
  }
  if (uf.find(S) != uf.find(T)) {
    cout << 0 << endl;
    cout << 0 << endl;
    cout << endl;
    exit(0);
  }
  nodes.assign(N, Node{});
  int time = 0;
  dfs(S, -1, time);
  vector<pair<int, int>> bridges;
  for (int i = 0; i < (N); ++i) {
    for (auto& e : ed[i]) {
      if (is_bridge(i, e)) {
        bridges.push_back({i, e.j});
      }
    }
  }
  for (auto& b : bridges) {
    int i = b.first, j = b.second;
    ed[i].push_back({j, -1, 0});
    ed[j].push_back({i, -1, 0});
  }
  PushRelabel pr(N);
  for (int i = 0; i < (N); ++i) {
    for (auto& e : ed[i]) {
      if (i < e.j) {
        pr.add_edge(i, e.j, e.ind, e.w + inf2, e.w + inf2);
      }
    }
  }
  long long flow = pr.maxflow(S, T);
  if (flow >= 3 * inf2) {
    cout << -1 << endl;
  } else {
    assert(flow >= 2 * inf2);
    long long res = 0;
    vector<int> resv;
    vector<int> seen(N);
    dfs3(pr.g, seen, S, res, resv);
    for (int i = 0; i < (N); ++i) {
      if (!seen[i]) continue;
      for (auto& e : pr.g[i]) {
        if (seen[e.dest]) continue;
        res += e.f;
        if (e.id != -1) resv.push_back(e.id);
      }
    }
    assert(res == flow);
    assert((int)(resv).size() <= 2);
    flow -= 2 * inf2;
    cout << flow << endl;
    cout << (int)(resv).size() << endl;
    sort(resv.begin(), resv.end());
    for (auto& x : resv) {
      cout << x << ' ';
    }
    cout << endl;
  }
  exit(0);
}
