This is an approximate problem.
Let's define tree TK in the following way:
1. T1 is a tree with just one vertrex.
2. If K>1 then let D be the biggest integer such that D|K and 1≤D<K. The tree TK will be the union of TK−1 with vertex {K} and edge (D,K).
The image below represents the tree T8.
Two graphs G1=({A1,A2,…,AM},E1) & G2=({B1,B2,…,BM},E2) are isomorphic if there exists a permutation P of length M such that ∀ (i,j), (Ai,Aj)∈E1⟺(BPi,BPj)∈E2.
Given a tree F with N vertices. Let E be the set of edges. You need to delete some edges from the tree, such for every disjoint tree U in the remaining forest there exists an integer i such that U is isomorphic to Ti.
Input
The first line contains two integers - N, W.
The following N−1 lines contain two integers - U,V, meaning there is edge (U,V) in tree F.
Scoring
Suppose the sizes of the trees in the remaining forest are S1,S2,…,SL. Let R=∑Li=1S3iW, then your score will be equal to 10000min(1.25,R)+max(0,R−1.25)⋅10. You want to maximize this score.
Output
The first line contains one integer - L.
The (i+1)th line has the following format - Si,P1,P2,…,PSi. P is a set of vertices, representing a tree in the remaining forest. The condition ∀(x,y),(x,y)∈TSi⟺(Px,Py)∈E must be satisfied.
We must have that ∑Li=1Si=N. Every vertex must appear exactly once.
Test Generation
For the first 10 tests. At first, an array V of length K is generated uniformly under the conditions attached below. Then, we generate a forest containing trees TV1,TV2,…,TVK with indices from 1 to N. After this, random edges are added in order to transform the forest into tree F. W will be assigned value ∑Ki=1V3i.
The rest of the tests have random trees. W will be assigned value 21N.
Note that the tests are ordered in the same way as presented in the table above.
Test data will be regenerated with different seeds after the contest.
Suppose that K=2,V1=7,V2=4, then W=73+43=407. We created trees T7 with indices {1,5,6,7,9,10,11} and T4 with indices {2,3,4,8}. Next, to connect both trees, we add edge (9,2).
Note that we can also delete edges {(3,2),(2,4),(4,8)}, but then we would obtain a smaller cost equal to 73+4⋅13=347 compared to 73+43=407.