#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T &x) {
  x = 0;
  char c = getchar();
  int f = 1;
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) x = x * 10 - '0' + c, c = getchar();
  x *= f;
}
const int N = 2e4 + 10, M = 330010, inf = 1e7;
int n, m, ncnt, S, T;
int p[N][16], num[N][16], dep[N], pos[N], idx[N];
namespace Flow {
int head[M], cur[M], ecnt;
void init() { memset(head, -1, sizeof(head)); }
struct ED {
  int to, next, f;
};
vector<ED> e;
void ad(int x, int y, int w) {
  e.push_back((ED){y, head[x], w});
  head[x] = ecnt++;
  e.push_back((ED){x, head[y], 0});
  head[y] = ecnt++;
}
int dep[M], vis[M];
queue<int> q;
bool bfs() {
  memset(dep, -1, sizeof(dep));
  memcpy(cur, head, sizeof(cur));
  q.push(S), dep[S] = 0;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int k = head[u]; ~k; k = e[k].next)
      if (e[k].f) {
        int v = e[k].to;
        if (dep[v] == -1) dep[v] = dep[u] + 1, q.push(v);
      }
  }
  return dep[T] != -1;
}
int dfs(int u, int f) {
  if (u == T || !f) return f;
  int tmp, ret = 0;
  for (int &k = cur[u]; ~k; k = e[k].next)
    if (e[k].f) {
      int v = e[k].to;
      if (dep[v] == dep[u] + 1 && (tmp = dfs(v, min(f, e[k].f)))) {
        e[k].f -= tmp, e[k ^ 1].f += tmp;
        f -= tmp, ret += tmp;
        if (!f) break;
      }
    }
  return ret;
}
void print(int u) {
  if (vis[u]) return;
  vis[u] = 1;
  for (int k = head[u]; ~k; k = e[k].next)
    if (e[k].f) print(e[k].to);
}
vector<int> A1, A2;
void work() {
  int ans = 0;
  while (bfs()) ans += dfs(S, inf);
  print(S);
  printf("%d\n", ans);
  for (int i = 1; i < n; ++i)
    if (!vis[num[idx[i]][0]]) A1.push_back(i);
  for (int i = 1; i <= m; ++i)
    if (vis[pos[i]]) A2.push_back(i);
  printf("%d ", A2.size());
  for (int i = 0; i < A2.size(); ++i) printf("%d ", A2[i]);
  puts("");
  printf("%d ", A1.size());
  for (int i = 0; i < A1.size(); ++i) printf("%d ", A1[i]);
  puts("");
}
}  // namespace Flow
struct ed {
  int v, id;
};
vector<ed> E[N];
void dfs(int u, int last) {
  dep[u] = dep[last] + 1;
  p[u][0] = last, num[u][0] = ++ncnt, Flow::ad(S, num[u][0], 1);
  for (int j = 1; j <= 15; ++j) {
    p[u][j] = p[p[u][j - 1]][j - 1], num[u][j] = ++ncnt;
    Flow::ad(num[u][j - 1], num[u][j], inf),
        Flow::ad(num[p[u][j - 1]][j - 1], num[u][j], inf);
  }
  for (int i = 0; i < E[u].size(); ++i) {
    int v = E[u][i].v;
    if (v == last) continue;
    idx[E[u][i].id] = v;
    dfs(v, u);
  }
}
void Update(int x, int y, int to) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int j = 15; j >= 0; --j)
    if (dep[x] - (1 << j) >= dep[y]) Flow::ad(num[x][j], to, inf), x = p[x][j];
  if (x == y) return;
  for (int j = 15; j >= 0; --j)
    if (p[x][j] != p[y][j])
      Flow::ad(num[x][j], to, inf), Flow::ad(num[y][j], to, inf), x = p[x][j],
                                                                  y = p[y][j];
  Flow::ad(num[x][0], to, inf), Flow::ad(num[y][0], to, inf);
}
int main() {
  int x, y;
  read(n), read(m);
  Flow::init();
  S = ++ncnt, T = ++ncnt;
  for (int i = 1; i < n; ++i)
    read(x), read(y), E[x].push_back((ed){y, i}), E[y].push_back((ed){x, i});
  dfs(1, 0);
  for (int i = 1; i <= m; ++i)
    read(x), read(y), pos[i] = ++ncnt, Update(x, y, pos[i]),
                      Flow::ad(pos[i], T, 1);
  Flow::work();
  return 0;
}
