Organization of Transportation
In a certain country, a new trade-industrial enterprise is set to begin operations. Factories will be established in N cities with well-developed industries, while N shopping centers will open in another N cities that are favorable for trade. According to the plan, each factory must be paired with exactly one shopping center.
The challenge is to pair these factories and shopping centers and establish freight transport routes between them.
The complication arises from the country's underdeveloped road system. There are M cities in total, but only M–1 intercity highways, each connecting two cities. Fortunately, any two cities can be reached from one another. However, due to efforts to combat traffic congestion, the enterprise is restricted from establishing more than one route through any single city.
Your task is to determine if it is possible to design a system of routes that satisfies these conditions.
Input
The first line contains two integers M (2 ≤ M ≤ 10^5) and N (1 ≤ N ≤ M/2) – the total number of cities and the number of factories, respectively. The following M–1 lines each contain two integers, ranging from 1 to M, separated by a space, representing pairs of cities connected by highways. Then, two additional lines follow, each containing N integers separated by spaces: the first line lists the cities where the factories are located, and the second line lists the cities where the shopping centers are located.
Output
Output YES if it is possible to construct a system of non-overlapping routes that pair each factory with a shopping center. Otherwise, output NO.