shell

Time limit: 0.5s Memory limit: 512MB Input: Output:

Florin is again in Drobeta-Turnu Severin. Unfortunately, he did not get rid off the pickpockets that bother him so much! They followed him even in this beautiful city! But Florin is very smart and figured out how to get rid of them. Drobeta-Turnu Severin is a city that is represented by a directed acyclic graph with nn vertices and mm edges. To finally get rid of those annoying pickpockets, Florin (who is initially in vertex 11) has to reach vertex nn using a certain path. He managed to obtain a list of pp vertices. In his way from vertex 11 to vertex nn he has to cross all these pp nodes in the given order, or else he will not get rid of the pickpockets and our hero will be very upset.

Task

Find the number of possible paths from vertex 11 to vertex nn that cross all pp vertices in the given order from the list. Because the result can be very big you have to print the answer modulo 1 000 000 0071 \ 000 \ 000 \ 007.

Input

The first line contains three integers nn, mm and pp.

The second line contains the pp vertices that have to be crossed by Florin in the given order.

The next mm lines contain the edges from the graph, represented by two integers xx and yy, meaning there is an edge from vertex xx to vertex yy.

Output

The first line will contain only one integer representing the number of paths modulo 1 000 000 0071 \ 000 \ 000 \ 007.

Restrictions

  • WARNING! There can be more edges between the same 2 vertices!!!!
  • WARNING! It can be observed that at subtask 3, mm is bigger than at the subtask.
  • You have to print the answer modulo 1 000 000 0071 \ 000 \ 000 \ 007.
  • We had no good reason to name this problem shell.
# Points Restrictions
1 10 n20,m190,p11n \leq 20, m \leq 190, p \leq 11
2 45 n1 000,m30 000,p1 000n \leq 1 \ 000, m \leq 30 \ 000, p \leq 1 \ 000
3 20 n1 500,p1 500n \leq 1 \ 500, p \leq 1 \ 500 and there is an unique edge from any vertex xx to any vertex yy with x<yx < y (also there are no other edges)
4 25 n,m,p1 000 000n, m, p \leq 1 \ 000 \ 000

Example

stdin

6 9 3
3 5 6
1 3
1 3
1 2
2 3
2 4
3 4
3 5
4 5
5 6 

stdout

6

Explanation

The 66 paths are:

  1. 13561 \to 3 \to 5 \to 6
  2. 134561 \to 3 \to 4 \to 5 \to 6
  3. 13561 \to 3 \to 5 \to 6
  4. 134561 \to 3 \to 4 \to 5 \to 6
  5. 123561 \to 2 \to 3 \to 5 \to 6
  6. 1234561 \to 2 \to 3 \to 4 \to 5 \to 6

It can be observed that 134561 \to 3 \to 4 \to 5 \to 6 appears 22 times, this is because there are 22 edges from 11 to 33. One of the paths use an edge, the second one uses the other edge. The same situation is for 13561 \to 3 \to 5 \to 6.

Log in or sign up to be able to send submissions!