Under construction

Still being built. Things may change

Social Distancing

Time limit10sMemory limit512 MB

Summary
Move k students on a tree onto the k computer rooms one adjacent step at a time, keeping students at least two rooms apart, or report NO.
Level

Hard8 of 10

Topics
Tree, Simulation, Implementation
Solved
No attempts yet

Statement

Two things can be said about students. They hate doing more work than necessary, and they love distancing themselves from others. The first is probably why the department forms a tree (building a corridor between two indirectly connected rooms would be a waste of time). The second is why they thrive during the ongoing pandemic. Social distancing is no longer a luxury. It is the norm!

However, tree-structured buildings and distancing from others do not go well together. Currently there are kk students in some of the rooms, and under the distancing policy each room holds at most one student. Also, no two students are in rooms directly connected by a corridor.

The ICPC competition starts soon, and students rush to take seats at the computers scattered around the department. There are kk computers, as many as there are students, placed in some of the rooms. No two computers share a room, and no two directly connected rooms both have a computer. Students can assign themselves to computers in any way, but they must keep social distancing at all times. Getting them to their seats can be tricky, if not impossible.

You are a ruthless ICPC organizer and the creator of the ultimate killer problemset. Watching students run around frantically, you realize a horrible truth: if the students do not reach their rooms in time, they cannot take part in the competition, and all the hard work on unsolvable problems goes to waste. You cannot allow this.

Given the current positions of the students and the computers, design a sequence of operations that moves every student to a room with a computer. Each operation moves one student to an adjacent room. After every operation, no two students may be in the same room or in two adjacent rooms. You may perform at most 4n24n^2 moves, where nn is the number of rooms. The task may be impossible, but there is only one way to find out.

Input

The first line of input contains the number of test cases zz (1≤z≤100 0001 \leq z \leq 100\,000). The descriptions of the test cases follow.

The first line of a test case contains a single integer nn (2≤n≤2 0002 \leq n \leq 2\,000), the number of rooms at the department.

The next n−1n - 1 lines contain two integers uiu_i, viv_i each (1≤ui≠vi≤n1 \leq u_i \neq v_i \leq n), two rooms connected by a corridor. The corridors form a tree (a connected graph without cycles).

The next line contains a single integer kk (1≤k<n1 \leq k < n), the number of students (and computers).

The next line contains integers s1,…,sks_1, \ldots, s_k (1≤s1<s2<⋯<sk≤n1 \leq s_1 < s_2 < \cdots < s_k \leq n), the initial locations of the students.

The next line contains integers c1,…,ckc_1, \ldots, c_k in the same format, denoting the rooms with computers.

It is guaranteed that at least one student is located in a room without a computer.

The sum of n2n^2 over all test cases does not exceed 4⋅1074 \cdot 10^7.

Output

For each test case, output YES if it is possible to move the students to rooms with computers while maintaining social distancing, and NO otherwise. In the former case, print any valid solution on the following lines. The solution starts with a single integer mm (1≤m≤4n21 \leq m \leq 4n^2), the number of moves. Then mm lines follow, each with two integers aia_i, bib_i (1≤ai≠bi≤n1 \leq a_i \neq b_i \leq n), meaning that the student currently in room aia_i moves to room bib_i, which is connected to aia_i by a corridor.

You do not need to minimize the length of the solution.

Examples1

  1. Example 1

    Input
    2
    5
    1 2
    1 3
    2 4
    2 5
    2
    1 4
    1 5
    7
    1 2
    2 3
    2 4
    4 6
    6 5
    6 7
    3
    1 4 5
    3 4 7
    
    Expected output
    YES
    4
    1 3
    4 2
    2 5
    3 1
    NO