#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  x = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + c - 48, c = getchar();
}
const int maxn = 8e5 + 5, INF = 1e9;
int S, T, n, m, tot = 1, p, idx, ft[maxn], first[maxn], f[maxn][20],
                id[maxn][20], dep[maxn], idm[maxn];
vector<int> G[maxn], H[maxn];
struct Road {
  int u, t, w, nxt;
} eage[maxn << 1];
void add(int x, int y, int z) {
  eage[++tot] = (Road){x, y, z, first[x]};
  first[x] = tot;
}
void link(int x, int y, int z) {
  add(x, y, z);
  add(y, x, 0);
}
void frdfs(int x, int fa) {
  dep[x] = dep[fa] + 1;
  f[x][0] = fa, id[x][0] = ++idx;
  for (int i = 1; (1 << i) <= dep[x]; ++i) {
    f[x][i] = f[f[x][i - 1]][i - 1], id[x][i] = ++idx;
    link(id[x][i], id[x][i - 1], INF);
    link(id[x][i], id[f[x][i - 1]][i - 1], INF);
  }
  for (int i = 0; i < G[x].size(); ++i)
    if (G[x][i] != fa) ft[G[x][i]] = H[x][i], frdfs(G[x][i], x);
}
int LCA(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = 0, t = dep[x] - dep[y]; i <= p; ++i)
    if (t >> i & 1) x = f[x][i];
  if (x == y) return x;
  for (int i = p; i >= 0; --i)
    if (f[x][i] ^ f[y][i]) x = f[x][i], y = f[y][i];
  return f[x][0];
}
void Upd(int x, int y, int P, int lca = 0) {
  link(S, P, 1);
  lca = LCA(x, y);
  for (int i = p; i >= 0; --i)
    if (f[x][i] && dep[f[x][i]] >= dep[lca])
      link(P, id[x][i], INF), x = f[x][i];
  for (int i = p; i >= 0; --i)
    if (f[y][i] && dep[f[y][i]] >= dep[lca])
      link(P, id[y][i], INF), y = f[y][i];
}
struct Network_Flow {
  int f, fm, d[maxn];
  int bfs(int S, int T) {
    queue<int> q;
    for (int i = 0; i <= idx; ++i) d[i] = 0;
    d[S] = 1;
    q.push(S);
    while (!q.empty()) {
      int x = q.front();
      q.pop();
      for (int i = first[x]; i; i = eage[i].nxt)
        if (eage[i].w && !d[eage[i].t]) {
          d[eage[i].t] = d[x] + 1;
          q.push(eage[i].t);
          if (eage[i].t == T) return 1;
        }
    }
    return 0;
  }
  int dfs(int x, int fl) {
    if (x == T) return fl;
    int lst = fl, q;
    for (int i = first[x]; i && lst; i = eage[i].nxt)
      if (eage[i].w && d[eage[i].t] == d[x] + 1) {
        q = dfs(eage[i].t, min(lst, eage[i].w));
        lst -= q;
        eage[i].w -= q;
        eage[i ^ 1].w += q;
        if (!q) d[eage[i].t] = 0;
      }
    return fl - lst;
  }
  int Dinic() {
    while (bfs(S, T))
      if (f = dfs(S, INF)) fm += f;
    return fm;
  }
} nf;
int main() {
  read(n);
  read(m);
  p = log(n) / log(2) + 1;
  for (int i = 1, x, y; i < n; ++i) {
    read(x), read(y);
    G[x].push_back(y), G[y].push_back(x);
    H[x].push_back(i), H[y].push_back(i);
  }
  frdfs(1, 0);
  for (int i = 1, x, y; i <= m; ++i)
    read(x), read(y), Upd(x, y, idm[i] = ++idx);
  T = ++idx;
  for (int i = 2; i <= n; ++i) link(id[i][0], T, 1);
  printf("%d\n", nf.Dinic());
  nf.bfs(S, T);
  vector<int> bl;
  for (int i = 1; i <= m; ++i)
    if (!nf.d[idm[i]]) bl.push_back(i);
  printf("%d ", (int)bl.size());
  sort(bl.begin(), bl.end());
  for (int i = 0; i < bl.size(); ++i) printf("%d ", bl[i]);
  puts("");
  bl.clear();
  for (int i = 2; i <= n; ++i)
    if (nf.d[id[i][0]]) bl.push_back(ft[i]);
  printf("%d ", (int)bl.size());
  sort(bl.begin(), bl.end());
  for (int i = 0; i < bl.size(); ++i) printf("%d ", bl[i]);
  puts("");
  return 0;
}
