A zoo has a entrance gates (numbered 1 to a), n animal enclosures (numbered a+1 to a+n), and b exit gates (numbered a+n+1 to a+n+b). Paths connect entrance gates to enclosures, enclosures to other enclosures, and enclosures to exit gates. Every path is bidirectional, and no two paths cross (some run through tunnels or over footbridges, so this is possible).
A class visits the zoo for a nature lesson. The teacher picked k students, each responsible for one animal, and the students strung their talks together into a single story. The tour must visit the enclosures of the chosen animals in the order fixed by that story. The route must satisfy:
Entering through any gate, visiting the animals' enclosures in story order, and leaving through any exit gate, find the minimum number of enclosures the route passes through. If no such route exists, output −1.
The first line contains five integers a, n, b, k, m (1≤a≤25, 1≤b≤25, 1≤k≤100, 1≤n≤1000, 1≤m≤5000): the number of entrance gates, enclosures, exit gates, chosen animals, and paths.
Each of the next k lines contains the enclosure number of one chosen animal, given in story order (each animal appears at most once).
Each of the next m lines describes one path as two distinct integers: the numbers of the two gates or enclosures it directly connects.
Print a single line: −1 if no route satisfying the rules exists, otherwise the minimum number of enclosures the route must pass through (including the chosen animals' enclosures, counting an enclosure once for each time it is passed through).