Delivery System
Bill is the distributor for the “ByteLand Delivery System”. He has some orders to deliver. You have a map of ByteLand, and there are cities and directed ways. You also have a set of different cities where Bill has to make a delivery. You have to find a good order of cities for Bill to visit. The order is good if and only if, it's possible to reach City number from City number for each acceptable .
As you qualified to the semifinal, Bill thinks you are the one who can solve the problem he is facing!
If there are multiple solutions, print the lexicographically smallest.
Constraints
Input Format
First line contains one integer , number of testcases.
For each test:
First line contains three integers , and .
Second line contains integers, cities Bill has to visit.
Next line contains two integers and ,
denotes that there is a direct way from to .
Output Format
For each test print a line with lexicographically smallest answer,but if there is no answer print -1.
Sample Input
1
4 5 3
4 3 2
3 4
3 1
1 4
2 1
3 2
Sample Output
3 2 4
Explanation
Start from city 3 and go to city 4 in passing by 2 is good and lexicographically smallest.
xxxxxxxxxx
with Ada.Text_IO, Ada.Integer_Text_IO;
use Ada;
procedure Solution is
-- Enter your code here. Read input from STDIN. Print output to STDOUT
end Solution