#include <bits/stdc++.h>
using namespace std;
struct e {
  int to, f, p;
};
vector<e> mG[505050];
void adde(int a, int b, int c) {
  mG[a].push_back({b, c, (int)mG[b].size()});
  mG[b].push_back({a, 0, (int)mG[a].size() - 1});
}
int u[505050];
int flow(int x, int sink) {
  if (x == sink) return 1;
  if (u[x]) return 0;
  u[x] = 1;
  for (auto& ne : mG[x]) {
    if (ne.f) {
      int fl = flow(ne.to, sink);
      if (fl) {
        ne.f--;
        mG[ne.to][ne.p].f++;
        return 1;
      }
    }
  }
  return 0;
}
int nid;
int putflow(int source, int sink) {
  for (int i = 0; i < nid; i++) {
    u[i] = 0;
  }
  return flow(source, sink);
}
void dfs2(int x) {
  if (u[x]) return;
  u[x] = 1;
  for (auto ne : mG[x]) {
    if (ne.f) {
      dfs2(ne.to);
    }
  }
}
int up[20202][15];
int uv[20202][15];
int d[20202];
vector<pair<int, int> > g[20202];
int source;
int sink;
const int W = 1e6;
void dfs1(int x, int p, int pe) {
  if (p != 0) {
    up[x][0] = p;
    uv[x][0] = pe;
    adde(pe, sink, 1);
    for (int i = 1; i < 15; i++) {
      up[x][i] = up[up[x][i - 1]][i - 1];
      if (up[x][i] != 0) {
        uv[x][i] = nid++;
        adde(uv[x][i], uv[x][i - 1], W);
        adde(uv[x][i], uv[up[x][i - 1]][i - 1], W);
      }
    }
  }
  for (auto nx : g[x]) {
    if (nx.first != p) {
      d[nx.first] = d[x] + 1;
      dfs1(nx.first, x, nx.second);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n - 1; i++) {
    int a, b;
    cin >> a >> b;
    g[a].push_back({b, i});
    g[b].push_back({a, i});
  }
  source = n + m + 1;
  sink = n + m + 2;
  nid = n + m + 3;
  dfs1(1, 0, 0);
  for (int qq = 0; qq < m; qq++) {
    int x, y;
    cin >> x >> y;
    int tn = n + qq;
    adde(source, tn, 1);
    if (d[x] < d[y]) swap(x, y);
    for (int i = 14; i >= 0; i--) {
      if (d[x] - d[y] >= (1 << i)) {
        adde(tn, uv[x][i], W);
        x = up[x][i];
      }
    }
    assert(d[x] == d[y]);
    assert(x != 0 && y != 0);
    if (x == y) continue;
    for (int i = 14; i >= 0; i--) {
      if (up[x][i] != up[y][i]) {
        adde(tn, uv[x][i], W);
        adde(tn, uv[y][i], W);
        x = up[x][i];
        y = up[y][i];
      }
    }
    assert(x != 0 && y != 0);
    assert(x != y);
    adde(tn, uv[x][0], W);
    adde(tn, uv[y][0], W);
  }
  int ans = 0;
  while (int f = putflow(source, sink)) {
    ans += f;
  }
  for (int i = 0; i < nid; i++) {
    u[i] = 0;
  }
  cout << ans << endl;
  dfs2(source);
  vector<int> a1;
  for (int i = 0; i < m; i++) {
    if (!u[n + i]) {
      a1.push_back(i + 1);
    }
  }
  cout << a1.size() << " ";
  for (int x : a1) {
    cout << x << " ";
  }
  cout << endl;
  vector<int> a2;
  for (int i = 1; i <= n - 1; i++) {
    if (u[i]) {
      a2.push_back(i);
    }
  }
  cout << a2.size() << " ";
  for (int x : a2) {
    cout << x << " ";
  }
  cout << endl;
}
