시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 512 MB 0 0 0 0.000%

문제

Dinara has an integer $x$ and two $n$ arrays $a_1, \dots, a_n$, $b_1, \dots, b_n$. She makes an $n \times n$ matrix $M$ where

$$ M_{i, j} = \left\{\begin{matrix} x + a_i b_j & \mathrm{when}\ i = j \\ a_i b_j & \mathrm{otherwise} \end{matrix}\right. $$

Find the determinant of the matrix $M$ modulo $(10^9+7)$.

입력

The input consists of several test cases terminated by end-of-file.

The first line of each test case contains two integers $n$ and $x$. The second line contains $n$ integers $a_1, \dots, a_n$. The third line contains $n$ integers $b_1, \dots, b_n$.

출력

For each test case, print an integer which denotes the result.

제한

  • $1 \leq n \leq 10^5$
  • $0 \leq x, a_i, b_i \leq 10^9$
  • The sum of $n$ does not exceed $10^6$.

예제 입력 1

2 1
0 0
0 0
2 1
1000000000 1000000000
1000000000 1000000000
3 2
2 3 3
2 3 3

예제 출력 1

1
99
96