#include <bits/stdc++.h>
using namespace std;
const int N = 2e4 + 5, inf = 1e9, M = 6e5 + 5;
struct node {
  int to, nxt, nm;
} g[N << 1];
struct edge {
  int to, nxt, f;
} e[M << 1];
int n, m, hd[N], cmt = 1, k, s, t, maxf;
int cur[M], dp[M], head[M], cnt;
int a1, a2;
int pd[N << 1], pd2[N], vis[M];
queue<int> q;
void add(int u, int v, int nm) {
  g[++cnt] = (node){v, hd[u], nm};
  hd[u] = cnt;
}
void ad(int u, int v, int f) {
  e[++cmt] = (edge){v, head[u], f};
  head[u] = cmt;
  e[++cmt] = (edge){u, head[v], 0};
  head[v] = cmt;
}
int fa[N][16], mp[N][16], dep[N];
void ch(int u, int fat, int nm) {
  dep[u] = dep[fat] + 1;
  if (fat) {
    fa[u][0] = fat;
    mp[u][0] = nm;
  }
  for (int i = 1; (1 << i) < dep[u]; i++)
    fa[u][i] = fa[fa[u][i - 1]][i - 1], mp[u][i] = ++k,
    ad(k, mp[u][i - 1], inf), ad(k, mp[fa[u][i - 1]][i - 1], inf);
  for (int i = hd[u]; i; i = g[i].nxt)
    if (g[i].to != fat) ch(g[i].to, u, g[i].nm);
}
void lca(int x, int y, int num) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = 15; i >= 0; i--) {
    if (dep[fa[x][i]] >= dep[y]) {
      ad(num, mp[x][i], inf);
      x = fa[x][i];
    }
    if (x == y) return;
  }
  for (int i = 15; i >= 0; i--) {
    if (fa[x][i] != fa[y][i]) {
      ad(num, mp[x][i], inf);
      ad(num, mp[y][i], inf);
      x = fa[x][i];
      y = fa[y][i];
    }
  }
  ad(num, mp[x][0], inf);
  ad(num, mp[y][0], inf);
}
bool bfs() {
  for (int i = s; i <= t; i++) cur[i] = head[i], dp[i] = 0;
  dp[s] = 1;
  q.push(s);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = head[u]; i; i = e[i].nxt) {
      if (!e[i].f) continue;
      int v = e[i].to;
      if (!dp[v]) dp[v] = dp[u] + 1, q.push(v);
    }
  }
  return dp[t];
}
int dfs(int u, int fl) {
  if (u == t) return fl;
  int sf = 0;
  for (int i = cur[u]; i; i = e[i].nxt) {
    cur[u] = i;
    if (!e[i].f) continue;
    int v = e[i].to;
    if (dp[v] == dp[u] + 1) {
      int tmp = dfs(v, min(fl, e[i].f));
      sf += tmp;
      fl -= tmp;
      e[i].f -= tmp;
      e[i ^ 1].f += tmp;
      if (!fl) break;
    }
  }
  if (!fl) dp[u] = 0;
  return sf;
}
void dfs2(int u) {
  if (u > k && u < t) {
    if (!pd[u - k]) pd[u - k] = 1, a1++;
    return;
  }
  for (int i = head[u]; i; i = e[i].nxt) {
    if (!(i & 1)) continue;
    int v = e[i].to;
    dfs2(v);
  }
}
int main() {
  cin >> n >> m;
  k = n - 1;
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    add(u, v, i);
    add(v, u, i);
  }
  ch(1, 0, 0);
  s = 0;
  t = k + m + 1;
  for (int i = 1; i < n; i++) ad(i, t, 1);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    lca(x, y, i + k);
    ad(s, i + k, 1);
  }
  while (bfs()) maxf += dfs(s, inf);
  printf("%d\n", maxf);
  for (int i = 1; i <= m; i++)
    if (!dp[i + k]) a1++;
  printf("%d ", a1);
  for (int i = 1; i <= m; i++)
    if (!dp[i + k]) printf("%d ", i);
  for (int i = 1; i < n; i++)
    if (dp[i]) a2++;
  printf("\n%d ", a2);
  for (int i = 1; i < n; i++)
    if (dp[i]) printf("%d ", i);
}
