#include <bits/stdc++.h>
using namespace std;
struct edge {
  int to, nxt, flow;
} e[2000005];
int head[300000], cnte, cur[300000];
void insert(int u, int v, int f) {
  e[cnte] = (edge){v, head[u], f};
  head[u] = cnte++;
}
void adde(int u, int v, int f) {
  insert(u, v, f);
  insert(v, u, 0);
}
int g[300000], d[300000], n, m, N, S, T;
queue<int> q;
void bfs() {
  memset(d, -1, sizeof(d));
  memset(g, 0, sizeof(g));
  d[T] = 0;
  g[0] = 1;
  q.push(T);
  for (int i = 0; i <= N; i++) cur[i] = head[i];
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = head[u]; ~i; i = e[i].nxt) {
      int v = e[i].to;
      if (~d[v]) continue;
      d[v] = d[u] + 1;
      g[d[v]]++;
      q.push(v);
    }
  }
}
int maxflow;
int dfs(int u, int flow) {
  if (u == T) {
    maxflow += flow;
    return flow;
  }
  int ans = 0;
  for (int &i = cur[u]; ~i; i = e[i].nxt) {
    int v = e[i].to;
    if (d[v] == d[u] - 1 && e[i].flow) {
      int tmp = dfs(v, min(flow - ans, e[i].flow));
      e[i].flow -= tmp;
      e[i ^ 1].flow += tmp;
      ans += tmp;
      if (flow == ans) return ans;
    }
  }
  --g[d[u]];
  if (g[d[u]] == 0) d[S] = N + 1;
  d[u]++;
  cur[u] = head[u];
  g[d[u]]++;
  return ans;
}
void ISAP() {
  maxflow = 0;
  bfs();
  while (d[S] < N) dfs(S, 1e9);
}
struct Edge {
  int to, nxt, id;
} t[40005];
int Head[20005], cnt;
void Adde(int u, int v, int id) {
  t[++cnt] = (Edge){v, Head[u], id};
  Head[u] = cnt;
}
int fa[20005][20], id[20005][20], dep[20005], ID[20005];
void DFS(int u, int fat) {
  if (u != 1) adde(id[u][0] = ++N, m + u, 1e9);
  fa[u][0] = fat;
  dep[u] = dep[fat] + 1;
  for (int i = 1; (1 << i) <= dep[u]; i++)
    adde(id[u][i] = ++N, id[u][i - 1], 1e9),
        adde(id[u][i], id[fa[u][i - 1]][i - 1], 1e9),
        fa[u][i] = fa[fa[u][i - 1]][i - 1];
  for (int i = Head[u]; i; i = t[i].nxt) {
    int v = t[i].to;
    if (v == fat) continue;
    ID[v] = t[i].id;
    DFS(v, u);
  }
}
int lca(int u, int v) {
  if (dep[u] < dep[v]) swap(u, v);
  for (int i = 19; i >= 0; i--)
    if (dep[u] - (1 << i) >= dep[v]) u = fa[u][i];
  if (u == v) return u;
  for (int i = 19; i >= 0; i--)
    if (fa[u][i] != fa[v][i]) u = fa[u][i], v = fa[v][i];
  return fa[u][0];
}
vector<int> ans;
bool vis[300000];
void DFS2(int u) {
  vis[u] = true;
  for (int i = head[u]; ~i; i = e[i].nxt)
    if (!vis[e[i].to] && e[i].flow) DFS2(e[i].to);
}
int main() {
  scanf("%d%d", &n, &m);
  N = n + m + 2;
  S = n + m + 1;
  T = n + m + 2;
  memset(head, -1, sizeof(head));
  for (int i = 1, u, v; i < n; i++)
    scanf("%d%d", &u, &v), Adde(u, v, i), Adde(v, u, i);
  for (int i = 1; i <= m; i++) adde(S, i, 1);
  for (int i = 2; i <= n; i++) adde(m + i, T, 1);
  dep[0] = -1;
  DFS(1, 0);
  for (int j = 1, u, v; j <= m; j++) {
    scanf("%d%d", &u, &v);
    int LCA = lca(u, v);
    for (int i = 19; i >= 0; i--)
      if (dep[u] - (1 << i) >= dep[LCA]) adde(j, id[u][i], 1e9), u = fa[u][i];
    for (int i = 19; i >= 0; i--)
      if (dep[v] - (1 << i) >= dep[LCA]) adde(j, id[v][i], 1e9), v = fa[v][i];
  }
  ISAP();
  cout << maxflow << endl;
  DFS2(S);
  for (int i = 1; i <= m; i++)
    if (!vis[i]) ans.push_back(i);
  printf("%d", ans.size());
  for (int u : ans) printf(" %d", u);
  puts("");
  ans.clear();
  for (int i = 2; i <= n; i++)
    if (vis[id[i][0]]) ans.push_back(ID[i]);
  printf("%d", ans.size());
  for (int u : ans) printf(" %d", u);
  return 0;
}
