#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
map<pair<int, int>, int> edge;
vector<int> ee, pp;
int n, m, cnt = 1, hd[100005];
int read() {
  int f = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    f = f * 10 + ch - '0';
    ch = getchar();
  }
  return f * w;
}
struct node {
  int to, next, dis;
} e[4000005];
void addedge(int x, int y, int z) {
  e[++cnt].dis = z;
  e[cnt].next = hd[x];
  e[cnt].to = y;
  hd[x] = cnt;
}
void add(int x, int y, int z) { addedge(x, y, z), addedge(y, x, 0); }
namespace dinic {
int dis[100005], s, t;
bool vis[100005];
bool bfs() {
  queue<int> q;
  q.push(s);
  memset(dis, 0x3f, sizeof(dis));
  dis[s] = 0;
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int i = hd[x]; i; i = e[i].next) {
      int to = e[i].to;
      if (dis[to] == inf && e[i].dis > 0) {
        dis[to] = dis[x] + 1;
        q.push(to);
      }
    }
  }
  return dis[t] != inf;
}
int dinic(int x, int flow) {
  if (x == t) return flow;
  int sum = 0;
  for (int i = hd[x]; i && flow; i = e[i].next) {
    int to = e[i].to;
    if (dis[to] == dis[x] + 1 && e[i].dis > 0) {
      int y = dinic(to, min(flow, e[i].dis));
      if (!y) dis[to] = inf;
      e[i].dis -= y, e[i ^ 1].dis += y, sum += y, flow -= y;
    }
  }
  return sum;
}
void dfs(int x) {
  vis[x] = 1;
  for (int i = hd[x]; i; i = e[i].next) {
    int to = e[i].to;
    if (e[i].dis > 0 && !vis[to]) dfs(to);
  }
}
int solve() {
  int res = 0;
  while (bfs()) res += dinic(s, inf);
  return res;
}
}  // namespace dinic
namespace seg {
int id[100005];
void build(int tr, int l, int r) {
  if (l == r) {
    add(tr, dinic::t, 1);
    id[tr] = l;
    return;
  }
  int mid = (l + r) / 2;
  add(tr, tr * 2, inf), add(tr, tr * 2 + 1, inf);
  build(tr * 2, l, mid), build(tr * 2 + 1, mid + 1, r);
}
void modify(int tr, int stdl, int stdr, int l, int r, int k) {
  if (l > stdr || r < stdl) return;
  if (l <= stdl && r >= stdr) {
    add(k, tr, inf);
    return;
  }
  int mid = (stdl + stdr) / 2;
  modify(tr * 2, stdl, mid, l, r, k),
      modify(tr * 2 + 1, mid + 1, stdr, l, r, k);
}
}  // namespace seg
namespace hld {
int dfn[100005], rev[100005], id[100005], dfn_cnt, son[100005], top[100005],
    siz[100005], dep[100005], fa[100005];
vector<int> g[100005];
void dfs_son(int x, int ff) {
  id[x] = edge[make_pair(x, ff)];
  dep[x] = dep[ff] + 1;
  siz[x] = 1;
  fa[x] = ff;
  int maxson = -1;
  for (int to : g[x]) {
    if (to == ff) continue;
    dfs_son(to, x);
    siz[x] += siz[to];
    if (siz[to] > maxson) maxson = siz[to], son[x] = to;
  }
}
void dfs_chain(int x, int tp) {
  dfn[x] = ++dfn_cnt;
  rev[dfn_cnt] = x;
  top[x] = tp;
  if (son[x]) dfs_chain(son[x], tp);
  for (int to : g[x]) {
    if (dfn[to]) continue;
    dfs_chain(to, to);
  }
}
void modify(int x, int y, int k) {
  while (top[x] != top[y]) {
    if (dep[top[x]] < dep[top[y]]) swap(x, y);
    seg::modify(1, 1, n, dfn[top[x]], dfn[x], k);
    x = fa[top[x]];
  }
  if (dfn[x] > dfn[y]) swap(x, y);
  if (x != y) seg::modify(1, 1, n, dfn[x] + 1, dfn[y], k);
}
}  // namespace hld
int main() {
  n = read(), m = read();
  for (int i = 1; i < n; i++) {
    int x = read(), y = read();
    edge[make_pair(x, y)] = edge[make_pair(y, x)] = i;
    hld::g[x].push_back(y), hld::g[y].push_back(x);
  }
  hld::dfs_son(1, 0), hld::dfs_chain(1, 1);
  dinic::s = m + 4 * n + 1, dinic::t = m + 4 * n + 2;
  seg::build(1, 1, n);
  for (int i = 1; i <= m; i++) {
    int l = read(), r = read();
    hld::modify(l, r, 4 * n + i);
    add(dinic::s, 4 * n + i, 1);
  }
  int ans = dinic::solve();
  printf("%d\n", ans);
  dinic::dfs(dinic::s);
  for (int i = hd[dinic::s]; i; i = e[i].next) {
    int to = e[i].to;
    if (!dinic::vis[to]) pp.push_back(to - 4 * n);
  }
  for (int i = hd[dinic::t]; i; i = e[i].next) {
    int to = e[i].to;
    if (dinic::vis[to]) ee.push_back(hld::id[hld::rev[seg::id[to]]]);
  }
  printf("%d ", pp.size());
  for (int j : pp) printf("%d ", j);
  printf("\n");
  printf("%d ", ee.size());
  for (int j : ee) printf("%d ", j);
  printf("\n");
  return 0;
}
