func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 10100, M = 1001000, oo = 1000000000;   int i, j, k, n, m, ch, Pn, Tn, En, x, y, fx, fy, rt, nm;   int h[N * 2], p[N * 2], g[N * 2], tmp[N * 2];   struct edge {     int s, n;   } E[N * 4];   struct edge2 {     int s, n, v;   };   struct tree {     int l, r;   } T[N * 4];   struct point {     int fa, sz, dp, sn, tp, fv;   } P[N * 2];   int min(const int &x, const int &y) {     if (x < y) return x;     return y;   }   struct network {     int i, j, k, S, T, En, ans;     int z[N * 5], c[N * 5], d[N * 5], h[N * 5];     edge2 E[M];     void add(int x, int y, int v) {       E[++En].s = y;       E[En].v = v;       E[En].n = h[x];       h[x] = En;       E[++En].s = x;       E[En].v = 0;       E[En].n = h[y];       h[y] = En;     }     bool bfs() {       for (i = 1; i <= T; i++) c[i] = 0;       c[S] = 1;       d[1] = S;       i = 0;       j = 1;       while (i < j) {         i++;         for (k = h[d[i]]; k; k = E[k].n)           if (E[k].v && !c[E[k].s]) {             c[E[k].s] = c[d[i]] + 1;             d[++j] = E[k].s;             if (E[k].s == T) return 1;           }       }       return c[T];     }     void bfs2() {       z[S] = 1;       d[1] = S;       i = 0;       j = 1;       while (i < j) {         i++;         for (k = h[d[i]]; k; k = E[k].n)           if (E[k].v && !z[E[k].s]) {             z[E[k].s] = 1;             d[++j] = E[k].s;           }       }     }     int dfs(int x, int y) {       if (x == T || !y) return y;       int k, t, Y = y;       for (k = h[x]; k; k = E[k].n)         if (E[k].v && c[x] + 1 == c[E[k].s]) {           t = dfs(E[k].s, min(y, E[k].v));           y -= t;           E[k].v -= t;           E[k ^ 1].v += t;           if (!y) return Y;         }       if (y == Y) c[x] = -1;       return Y - y;     }     int work() {       ans = 0;       while (bfs()) ans += dfs(S, oo);       bfs2();       return ans;     }   } Net;   void R(int &x) {     x = 0;     ch = getchar();     while (ch <  0  ||  9  < ch) ch = getchar();     while ( 0  <= ch && ch <=  9 ) x = x * 10 + ch -  0 , ch = getchar();   }   void dfs1(int x, int F) {     P[x].sz = 1;     P[x].dp = P[F].dp + 1;     P[x].fa = F;     for (int k = h[x]; k; k = E[k].n)       if (E[k].s != F) {         tmp[E[k].s] = (k + 1) / 2;         dfs1(E[k].s, x);         P[x].sz += P[E[k].s].sz;         if (P[E[k].s].sz > P[P[x].sn].sz) P[x].sn = E[k].s;       }   }   void dfs2(int x, int F, int tp) {     P[x].fv = ++Pn;     p[Pn] = x;     P[x].tp = tp;     if (P[x].sn) dfs2(P[x].sn, x, tp);     for (int k = h[x]; k; k = E[k].n)       if (E[k].s != F && E[k].s != P[x].sn) dfs2(E[k].s, x, E[k].s);   }   void T_build(int L, int R, int &k) {     k = ++Tn;     if (L == R) {       Net.add(m + k, Net.T, 1);       g[p[L]] = m + k;       return;     }     int mid = (L + R) >> 1;     T_build(L, mid, T[k].l);     T_build(mid + 1, R, T[k].r);     Net.add(m + k, m + T[k].l, oo);     Net.add(m + k, m + T[k].r, oo);   }   void T_add(int L, int R, int l, int r, int x, int k) {     if (L == l && R == r) {       Net.add(x, m + k, oo);       return;     }     int mid = (L + R) >> 1;     if (r <= mid)       T_add(L, mid, l, r, x, T[k].l);     else {       if (l > mid)         T_add(mid + 1, R, l, r, x, T[k].r);       else         T_add(L, mid, l, mid, x, T[k].l),             T_add(mid + 1, R, mid + 1, r, x, T[k].r);     }   }   void E_add(int x, int y) {     E[++En].s = y;     E[En].n = h[x];     h[x] = En;     E[++En].s = x;     E[En].n = h[y];     h[y] = En;   }   int main() {     R(n);     R(m);     Net.En = 1;     Net.S = m + 2 * n;     Net.T = Net.S + 1;     for (i = 1; i < n; i++) {       R(x);       R(y);       E_add(x, y);     }     dfs1(1, 0);     dfs2(1, 0, 1);     T_build(1, n, rt);     for (i = 1; i <= m; i++) {       Net.add(Net.S, i, 1);       R(x);       R(y);       fx = P[x].tp;       fy = P[y].tp;       while (fx != fy) {         if (P[fx].dp > P[fy].dp) {           T_add(1, n, P[fx].fv, P[x].fv, i, rt);           x = P[fx].fa;           fx = P[x].tp;         } else {           T_add(1, n, P[fy].fv, P[y].fv, i, rt);           y = P[fy].fa;           fy = P[y].tp;         }       }       if (x != y) {         if (P[x].dp < P[y].dp)           T_add(1, n, P[x].fv + 1, P[y].fv, i, rt);         else           T_add(1, n, P[y].fv + 1, P[x].fv, i, rt);       }     }     printf( %d n , Net.work());     nm = 0;     for (i = 1; i <= m; i++)       if (!Net.z[i]) nm++;     printf( %d  , nm);     for (i = 1; i <= m; i++)       if (!Net.z[i]) printf( %d  , i);     puts(  );     nm = 0;     for (i = 2; i <= n; i++)       if (Net.z[g[i]]) nm++;     printf( %d  , nm);     for (i = 2; i <= n; i++)       if (Net.z[g[i]]) printf( %d  , tmp[i]);     puts(  );   }   