#include <bits/stdc++.h>
using namespace std;
const int N = 20005;
const int M = 400005;
vector<pair<int, int> > E[N];
int dep[N], fa[N][16], fav[N][16];
int n, m, S, T, nd, jud[N * 2];
int head[M], vis[M], tot = 1;
int dis[M], q[M];
struct edge {
  int to, next, f;
} e[M * 5];
void add(int x, int y, int f) {
  e[++tot] = (edge){y, head[x], f};
  head[x] = tot;
  e[++tot] = (edge){x, head[y], 0};
  head[y] = tot;
}
bool bfs() {
  for (int i = (int)(1); i <= (int)(nd); i++) dis[i] = -1;
  int h = 0, t = 1;
  q[1] = S;
  dis[S] = 0;
  while (h != t) {
    int x = q[++h];
    for (int i = head[x]; i; i = e[i].next)
      if (dis[e[i].to] == -1 && e[i].f) {
        dis[e[i].to] = dis[x] + 1;
        if (e[i].to == T) return 1;
        q[++t] = e[i].to;
      }
  }
  return 0;
}
int dfs(int x, int flow) {
  if (x == T) return flow;
  int k, rest = flow;
  for (int i = head[x]; i && rest; i = e[i].next)
    if (dis[e[i].to] == dis[x] + 1 && e[i].f) {
      k = dfs(e[i].to, min(rest, e[i].f));
      e[i].f -= k;
      e[i ^ 1].f += k;
      rest -= k;
    }
  if (rest) dis[x] = -1;
  return flow - rest;
}
void dfs(int x) {
  for (auto i : E[x])
    if (i.first != fa[x][0]) {
      dep[i.first] = dep[x] + 1;
      fa[i.first][0] = x;
      fav[i.first][0] = i.second;
      dfs(i.first);
    }
}
int LCA(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  int tmp = dep[x] - dep[y];
  for (int i = (int)(14); i >= (int)(0); i--)
    if (tmp & (1 << i)) x = fa[x][i];
  for (int i = (int)(14); i >= (int)(0); i--)
    if (fa[x][i] != fa[y][i]) x = fa[x][i], y = fa[y][i];
  return x == y ? x : fa[x][0];
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (int)(1); i <= (int)(n - 1); i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    E[x].push_back(pair<int, int>(y, i));
    E[y].push_back(pair<int, int>(x, i));
  }
  S = nd = n;
  T = ++nd;
  for (int i = (int)(1); i <= (int)(n - 1); i++) add(S, i, 1), jud[i] = tot;
  for (int i = (int)(1); i <= (int)(m); i++) add(++nd, T, 1), jud[i + n] = tot;
  dfs(1);
  for (int i = (int)(1); i <= (int)(14); i++)
    for (int j = (int)(1); j <= (int)(n); j++) {
      fa[j][i] = fa[fa[j][i - 1]][i - 1];
      if (dep[j] >= 1 << i) {
        fav[j][i] = ++nd;
        add(fav[j][i - 1], fav[j][i], 1 << 30);
        add(fav[fa[j][i - 1]][i - 1], fav[j][i], 1 << 30);
      }
    }
  for (int i = (int)(1); i <= (int)(m); i++) {
    int p = n + 1 + i, x, y;
    scanf("%d%d", &x, &y);
    int L = LCA(x, y);
    for (int j = (int)(14); j >= (int)(0); j--) {
      if (dep[x] - dep[L] >= 1 << j)
        add(fav[x][j], n + 1 + i, 1 << 30), x = fa[x][j];
      if (dep[y] - dep[L] >= 1 << j)
        add(fav[y][j], n + 1 + i, 1 << 30), y = fa[y][j];
    }
    assert(x == L && y == L);
  }
  int tmp = 0;
  for (; bfs(); tmp += dfs(S, 1 << 30))
    ;
  vector<int> ans1, ans2;
  for (int i = (int)(1); i <= (int)(n - 1); i++)
    if (dis[i] == -1) ans1.push_back(i);
  for (int i = (int)(1); i <= (int)(m); i++)
    if (dis[i + n + 1] != -1) ans2.push_back(i);
  assert(ans1.size() + ans2.size() == tmp);
  printf("%d\n", ans1.size() + ans2.size());
  printf("%d ", ans2.size());
  for (auto i : ans2) printf("%d ", i);
  puts("");
  printf("%d ", ans1.size());
  for (auto i : ans1) printf("%d ", i);
  puts("");
}
