#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e4 + 10, inf = 0x3f3f3f3f;
inline long long rd() {
  long long x = 0;
  char c = getchar();
  int neg = 1;
  while (c < '0' || c > '9') {
    if (c == '-') neg = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return x * neg;
}
struct Edge {
  int b, l, ne;
} ek[maxn * 100];
int N, M, ekh[maxn * 50], kct = 1;
int egh[maxn], eg[maxn * 2][2], ect = 1;
int dep[maxn * 40], fa[maxn][20], id[maxn][20], pct = 2;
int S = 1, T = 2, P[maxn];
int A[maxn], cur[maxn * 40];
bool flag[maxn * 40], B[maxn];
queue<int> q;
inline void adeg(int a, int b) {
  eg[++ect][0] = b;
  eg[ect][1] = egh[a];
  egh[a] = ect;
}
inline void adek(int a, int b, int c) {
  ek[++kct].b = b, ek[kct].l = c, ek[kct].ne = ekh[a], ekh[a] = kct;
  ek[++kct].b = a, ek[kct].l = 0, ek[kct].ne = ekh[b], ekh[b] = kct;
}
void dfs(int x) {
  for (int i = 0; fa[x][i] && fa[fa[x][i]][i]; i++) {
    fa[x][i + 1] = fa[fa[x][i]][i];
    id[x][i + 1] = ++pct;
    adek(id[x][i + 1], id[x][i], inf);
    adek(id[x][i + 1], id[fa[x][i]][i], inf);
  }
  for (int i = egh[x]; i; i = eg[i][1]) {
    int b = eg[i][0];
    if (b == fa[x][0]) continue;
    fa[b][0] = x;
    dep[b] = dep[x] + 1;
    id[b][0] = ++pct;
    adek(id[b][0], T, 1);
    dfs(b);
  }
}
void buildlca(int x, int y, int p) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = log2(dep[x] - dep[y]); i >= 0 && dep[x] != dep[y]; i--) {
    if (dep[fa[x][i]] >= dep[y]) {
      adek(p, id[x][i], 1);
      x = fa[x][i];
    }
  }
  if (x == y) return;
  for (int i = log2(dep[x]); i >= 0; i--) {
    if (fa[x][i] != fa[y][i]) {
      adek(p, id[x][i], 1);
      adek(p, id[y][i], 1);
      x = fa[x][i], y = fa[y][i];
    }
  }
  adek(p, id[x][0], 1);
  adek(p, id[y][0], 1);
}
bool bfs() {
  memset(dep, 0, sizeof(dep));
  memset(cur, -1, sizeof(cur));
  dep[S] = 1;
  q.push(S);
  while (!q.empty()) {
    int p = q.front();
    q.pop();
    for (int i = ekh[p]; i; i = ek[i].ne) {
      int b = ek[i].b;
      if (dep[b] || !ek[i].l) continue;
      dep[b] = dep[p] + 1;
      q.push(b);
    }
  }
  return dep[T];
}
int dinic(int x, int y) {
  if (x == T) return y;
  int tmp = y;
  if (cur[x] == -1) cur[x] = ekh[x];
  for (int &i = cur[x]; i; i = ek[i].ne) {
    int b = ek[i].b;
    if (dep[b] != dep[x] + 1 || !ek[i].l) continue;
    int re = dinic(b, min(ek[i].l, tmp));
    ek[i].l -= re, ek[i ^ 1].l += re;
    tmp -= re;
    if (!tmp) break;
  }
  return y - tmp;
}
void getans(int x) {
  flag[x] = 1;
  for (int i = ekh[x]; i; i = ek[i].ne) {
    int b = ek[i].b;
    if (!ek[i].l) continue;
    if (!flag[b]) getans(b);
  }
}
int main() {
  int i, j, k;
  N = rd(), M = rd();
  for (i = 1; i < N; i++) {
    int a = rd(), b = rd();
    adeg(a, b);
    adeg(b, a);
  }
  for (i = 1; i <= M; i++) P[i] = ++pct;
  dep[1] = 1;
  dfs(1);
  for (i = 1; i <= M; i++) {
    int a = rd(), b = rd();
    adek(S, P[i], 1);
    buildlca(a, b, P[i]);
  }
  int ans = 0, a = 0, b = 0;
  while (bfs()) ans += dinic(S, inf);
  getans(S);
  for (i = 3; i <= M + 2; i++)
    if (!flag[i]) A[++a] = i - 2;
  for (i = 2; i <= N; i++)
    if (flag[id[i][0]]) B[i] = 1, b++;
  printf("%d\n%d ", ans, a);
  for (i = 1; i <= a; i++) printf("%d ", A[i]);
  printf("\n%d ", b);
  for (i = 1; i < N; i++) {
    int x = eg[i << 1][0], y = eg[i << 1 | 1][0];
    if (fa[x][0] != y) swap(x, y);
    if (B[x]) printf("%d ", i);
  }
  return 0;
}
