QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 128 MB 満点: 100

#15150. Royal Federation

統計

The King of the "Yu" nation wants to reorganize his country. He wants to divide his country into several provinces, each managed by a member of his Royal Federation.

His country has $n$ cities, numbered $1..n$. Some cities are connected by roads, and there is exactly one direct or indirect path between any two distinct cities. To prevent management from being too fragmented, each province must have at least $B$ cities, and for effective management, each province must have at most $3B$ cities.

Each province must have a provincial capital. This capital can be located within the province or outside of it. However, for any city in the province, all cities on the path to the provincial capital (excluding the last city, which is the provincial capital itself) must belong to that province. A single city can serve as the provincial capital for multiple provinces.

Help the King!

Input

The first line contains two integers $N$ and $B$ ($1 \le N \le 1000$, $1 \le B \le N$). The next $N-1$ lines each describe an edge, containing two integers representing the IDs of the two cities connected by the edge.

Output

If it is impossible to satisfy the King's requirements, output $0$. Otherwise, output $K$ on the first line, representing the number of provinces in your partition scheme, numbered $1..K$. On the second line, output $N$ integers, where the $I$-th integer represents the ID of the province to which city $I$ belongs. On the third line, output $K$ integers, representing the city IDs of the provincial capitals for these $K$ provinces. If there are multiple valid schemes, you may output any one of them.

Examples

Input 1

8 2 
1 2 
2 3 
1 8 
8 7 
8 6 
4 6 
6 5

Output 1

3 
2 1 1 3 3 3 3 2 
2 1 8

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.