#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 30;
int n, m, cnt, S, T;
struct Network_flow {
  int tot, top;
  int head[510000], nex[10100000], to[10100000], val[10100000];
  int deep[510000], st[510000], pos[510000], vis[510000];
  queue<int> q;
  void init() {
    cnt = m;
    tot = 1;
    S = ++cnt;
    T = ++cnt;
  }
  void add(int x, int y, int v) {
    tot++;
    nex[tot] = head[x];
    head[x] = tot;
    to[tot] = y;
    val[tot] = v;
  }
  void ade(int x, int y, int v) {
    add(x, y, v);
    add(y, x, 0);
  }
  int bfs() {
    memset(deep, -1, sizeof(deep));
    while (!q.empty()) q.pop();
    q.push(S);
    deep[S] = 0;
    while (!q.empty()) {
      int t = q.front();
      q.pop();
      for (int i = head[t]; i; i = nex[i])
        if (val[i] && deep[to[i]] == -1) {
          deep[to[i]] = deep[t] + 1;
          q.push(to[i]);
          if (to[i] == T) return 1;
        }
    }
    return 0;
  }
  int dfs(int x, int mv) {
    if (x == T) return mv;
    int tmp = 0;
    for (int i = head[x]; i; i = nex[i])
      if (val[i] && deep[to[i]] == deep[x] + 1) {
        int t = dfs(to[i], min(mv - tmp, val[i]));
        if (!t) deep[to[i]] = -1;
        tmp += t;
        val[i] -= t;
        val[i ^ 1] += t;
        if (tmp == mv) break;
      }
    return tmp;
  }
  void dfs1(int x) {
    vis[x] = 1;
    for (int i = head[x]; i; i = nex[i])
      if (!vis[to[i]] && val[i]) dfs1(to[i]);
  }
  void work() {
    int ans = 0;
    while (bfs()) ans += dfs(S, inf);
    dfs1(S);
    printf("%d\n", ans);
    top = 0;
    for (int i = head[S]; i; i = nex[i])
      if (!vis[to[i]]) st[++top] = to[i];
    printf("%d ", top);
    for (int i = 1; i <= top; i++) printf("%d ", st[i]);
    puts("");
    top = 0;
    for (int i = head[T]; i; i = nex[i])
      if (vis[to[i]]) st[++top] = pos[to[i]];
    printf("%d ", top);
    for (int i = 1; i <= top; i++) printf("%d ", st[i]);
    puts("");
  }
} net;
struct Tree_dec {
  int tot;
  int head[21000], nex[21000 << 1], to[21000 << 1];
  int fa[21000][16], p[21000][16], deep[21000];
  void add(int x, int y) {
    tot++;
    nex[tot] = head[x];
    head[x] = tot;
    to[tot] = y;
  }
  void dfs(int x, int y) {
    deep[x] = deep[y] + 1;
    for (int i = 1; i <= 15; i++) {
      fa[x][i] = fa[fa[x][i - 1]][i - 1];
      p[x][i] = ++cnt;
      if (fa[x][i]) {
        net.ade(p[x][i], p[x][i - 1], inf);
        net.ade(p[x][i], p[fa[x][i - 1]][i - 1], inf);
      }
    }
    for (int i = head[x], t; i; i = nex[i])
      if ((t = to[i]) != y) {
        fa[t][0] = x;
        p[t][0] = ++cnt;
        net.ade(p[t][0], T, 1);
        net.pos[cnt] = i >> 1;
        dfs(t, x);
      }
  }
  void find(int x, int y, int ind) {
    net.ade(S, ind, 1);
    if (deep[x] < deep[y]) swap(x, y);
    for (int i = 15; i >= 0; i--)
      if (deep[fa[x][i]] >= deep[y]) {
        net.ade(ind, p[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]) {
        net.ade(ind, p[x][i], inf);
        net.ade(ind, p[y][i], inf);
        x = fa[x][i];
        y = fa[y][i];
      }
    net.ade(ind, p[x][0], inf);
    net.ade(ind, p[y][0], inf);
  }
} tr;
int main() {
  scanf("%d%d", &n, &m);
  tr.tot = 1;
  for (int i = 1, x, y; i < n; i++) {
    scanf("%d%d", &x, &y);
    tr.add(x, y);
    tr.add(y, x);
  }
  net.init();
  tr.dfs(1, 0);
  for (int x, y, i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    tr.find(x, y, i);
  }
  net.work();
  return 0;
}
