#D1992. Permutation

    ID: 1654 Type: Default 1000ms 134MiB

Permutation

Permutation

Problem statement

Find the number of integer sequences X1,X2,...,XN X_1, X_2, ..., X_N that satisfy the following conditions.

  1. For any integer i i (1 leqi leqN 1 \ leq i \ leq N ), there exists j j (1 leqj leqN 1 \ leq j \ leq N ) such that Xj=i X_j = i .
  2. Xs=t X_s = t
  3. Xai<Xbi X_ {a_i} <X_ {b_i} (1 leqi leqC 1 \ leq i \ leq C )

Constraint

  • 1 leqN leq2000 1 \ leq N \ leq 2000
  • 0 leqC leqN 0 \ leq C \ leq N
  • 1 leqs leqN 1 \ leq s \ leq N
  • 1 leqt leqN 1 \ leq t \ leq N
  • 1 leqai leqN 1 \ leq a_i \ leq N
  • 1 leqbi leqN 1 \ leq b_i \ leq N
  • ai neqbi a_i \ neq b_i
  • i neqj i \ neq j then ai neqaj a_i \ neq a_j

input

Input follows the following format. All given numbers are integers.

N N C C s s t t a1 a_1 b1 b_1 a2 a_2 b2 b_2 ... ... aC a_C bC b_C

output

Divide the number of sequences that satisfy the condition by 109+7 10 ^ 9 + 7 and output the remainder on one row (it is easy to show that the number of sequences that satisfy the condition is at most finite).

Examples

Input

3 1 1 1 1 3

Output

2

Input

4 2 1 1 2 3 3 2

Output

0

inputFormat

input

Input follows the following format. All given numbers are integers.

N N C C s s t t a1 a_1 b1 b_1 a2 a_2 b2 b_2 ... ... aC a_C bC b_C

outputFormat

output

Divide the number of sequences that satisfy the condition by 109+7 10 ^ 9 + 7 and output the remainder on one row (it is easy to show that the number of sequences that satisfy the condition is at most finite).

Examples

Input

3 1 1 1 1 3

Output

2

Input

4 2 1 1 2 3 3 2

Output

0

样例

3 1 1 1
1 3
2