Travel
Time limit1sMemory limit128 MB
Decide whether a simple cycle exists that uses two required roads and avoids all toll roads.
Problem
Kim works at a travel agency. A customer from abroad asked him to plan a trip. The customer insists on driving along two famous roads lined with flowers in full bloom. The trip works like this: the customer flies into some city, rents a car, drives a route, and returns to the very city where the trip started. The customer refuses to pass through the same city twice or drive the same road twice, and refuses to drive on any toll road. The number of cities on the route does not matter. Write a program that decides whether such a plan is possible.
For example, consider the maps in Figure 1. A circle is a city, and a line between two circles is a road joining them. The two bold lines are the famous roads the customer wants to drive, and the dotted line is a toll road.

Figure 1
In Figure 1(a), possible plans include 1 → 2 → 4 → 5 → 3 → 1 and 2 → 3 → 5 → 4 → 2. In Figure 1(b), no plan meets the requirements.
Given a map together with the two famous roads and the toll roads, decide whether a valid travel plan exists.
Input
The first line contains the number of test cases . Each test case has the following form.
The first line contains two integers and (): the number of cities and the number of roads. Each of the next lines contains two integers, the two cities joined by a road. The next two lines each contain one road that the customer wants to drive (the two famous roads). The next line contains an integer (), the number of toll roads, and each of the following lines contains one toll road.
Cities are labeled from to . There is at most one road between any two cities. Neither of the two famous roads is a toll road.
Output
For each test case, print a single line containing YES if a valid travel plan exists, and NO otherwise.