Shady Suburbs


Problem Statement

Will is trying to get home after a long day of work at university. Unfortunately for him, it's already 3am, and there are a lot shady people hiding at the end of some roads ready to jump on Will.

You are given a list of places that are shady, and a list of all roads in Melbourne. How many roads will Will have to cross before getting home?

Input

Your first line will contain vv and ee as space-separated integers. vv represents the number of suburbs in Melbourne, labelled from 00 to v−1v-1, and ee represents the number of roads in Melbourne.

Your next line will contain aa and bb as space-separated integers, indicating the locations of the university and Will's home.

Your next line will contain integer ss, indicating the total number of shady suburbs in Melbourne.

Your next line will contain bb space-separataed integers, each representing a suburb that is shady.

Your next ee lines will contain 22 space-separated numbers, specifying a road between the two suburbs.

Output

A single integer, representing the number of roads Will must cross before getting home without heading to any shady suburbs.

If no such path is possible, output −1-1 instead.

Constraints

For all test cases:

  • 2≤v≤1032 \le v \le 10^3
  • 0≤s≤v0 \le s \le v
  • 1≤e≤1061 \le e \le 10^6
  • a≠ba \ne b
  • All shady suburbs will be a valid value within the range of vv.

Example 1

Input 1
8 7
2 4
3
0 1 5
0 1
0 2
2 5
4 5
2 6
6 7
4 7
Output 1
3

Example 2

Input 2
3 2
0 2
1
1
0 1
1 2
Output 2
-1

Python Template

Code 1
v, e = map(int, input().split())
a, b = map(int, input().split(" "))
s = int(input())
blocked = list(map(int, input().split(" ")))
roads = [tuple(map(int, input().split(" "))) for _ in range(e)]

# print(...)

Comments0


No comments yet

Be the first to comment.

New comment


Log in to join the discussion.