No tags yet

No tag edit access

time limit per test: 0.5 sec.

memory limit per test: 65536 KB

memory limit per test: 65536 KB

input: standard

output: standard

output: standard

The king of Fooland has recently decided to reorganize his kingdom. Inspired by the democracy processes in neighbouring countries, he decided to convert his kingdom into Royal Federation. The Royal Federation would consist of several provinces, each headed by its governor.

There are N cities in his kingdom, numbered from 1 to N. Some cities are connected by roads. Roads are designed in such a way, that for each city there is exactly one way to get to any other city by the roads, not passing through any city more than once.

To prevent wastes for maintaining too small provinces, each province must contain at least B cities. However, to keep governments effective, each province must contain at most 3B cities.

Each province must have its governer headquaters in some city. This city may be outside the province itslef, but one must be able to get to the city with governer headquaters of his province in such a way, that all intermediate cities that he visits on his way belong to his province (and only the terminal city may be from another province).

One city may contain headquaters for several provinces.

Help the king to see his plans fulfilled.

There are N cities in his kingdom, numbered from 1 to N. Some cities are connected by roads. Roads are designed in such a way, that for each city there is exactly one way to get to any other city by the roads, not passing through any city more than once.

To prevent wastes for maintaining too small provinces, each province must contain at least B cities. However, to keep governments effective, each province must contain at most 3B cities.

Each province must have its governer headquaters in some city. This city may be outside the province itslef, but one must be able to get to the city with governer headquaters of his province in such a way, that all intermediate cities that he visits on his way belong to his province (and only the terminal city may be from another province).

One city may contain headquaters for several provinces.

Help the king to see his plans fulfilled.

The first line of the input file contains two integer numbers — N and B (1 ≤ N ≤ 10 000, 1 ≤ B ≤ N). Next N-1 lines contain descriptions of roads, each line contains two integer numbers — the cities the road connects.

If it is impossible to fulfil king's plans of reorganization, output 0 on the first line of the output file. In the other case output K — the number of provinces in your plan of the Royal Federation. After that output N integer numbers ranging from 1 to K — for each city output the number of the province it belongs to.

Finally output K integer numbers — the cities where the capitals of the provinces must be located in.

Input

8 2

1 2

2 3

1 8

8 7

8 6

4 6

6 5

1 2

2 3

1 8

8 7

8 6

4 6

6 5

Output

3

2 1 1 3 3 3 3 2

2 1 8

2 1 1 3 3 3 3 2

2 1 8

Author: | Andrew Stankevich |

Resource: | Petrozavodsk Summer Trainings 2003 |

Date: | 2003-08-30 |

Codeforces (c) Copyright 2010-2019 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Oct/19/2019 21:34:40 (h1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|