The ACM kingdom has N cities, numbered from 1 to N. The capital is numbered 1. There are N – 1 roads each connecting two cities in the kingdom such that there exactly one path between any pair of cities.
Now the Golden Week Vocation is coming. M travelers living in the capital are going to travel to other cities. Every traveler will start from the capital, and the ith traveler has chosen city Ci as his destination. As a manager of the travel agencies, Mr. Chopsticks decides to assign prices to the roads in the kingdom during the vocation. After some investigation, Mr. Chopsticks has found that every traveler has a budget for his trip, and if the total price of the roads in the path from the capital to his destination city is larger than his budget, he will give up his trip; otherwise he will pay for it to the travel agencies. Mr. Chopsticks wants to assign prices to roads so as to maximize the agencies’ revenue. Could you help him? Each road should be assigned a price between 0 and 1000,000,000 inclusive.