Wrocław Zoo

No attempts yetTime limit1sMemory limit128 MB

Problem

A zoo has aa entrance gates (numbered 1 to aa), nn animal enclosures (numbered a+1a+1 to a+na+n), and bb exit gates (numbered a+n+1a+n+1 to a+n+ba+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 kk 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:

  • It may start at any entrance gate.
  • It must visit the enclosures of all kk chosen animals.
  • It may end at any exit gate.
  • Apart from the start and the end, it may not pass through any gate.
  • It must respect the story order: it may not reach the enclosure of the ii-th chosen animal before it has visited the enclosure of animal i1i-1.
  • It must be as short as possible, that is, pass through as few enclosures as possible. An enclosure passed through several times is counted once for each time.

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-1.

Input

The first line contains five integers aa, nn, bb, kk, mm (1a251 \le a \le 25, 1b251 \le b \le 25, 1k1001 \le k \le 100, 1n10001 \le n \le 1000, 1m50001 \le m \le 5000): the number of entrance gates, enclosures, exit gates, chosen animals, and paths.

Each of the next kk lines contains the enclosure number of one chosen animal, given in story order (each animal appears at most once).

Each of the next mm lines describes one path as two distinct integers: the numbers of the two gates or enclosures it directly connects.

Output

Print a single line: 1-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).