#QHD0000017. Mô tả mảng (Array Description)

Mô tả mảng (Array Description)

Array Description

Source: CSES

Version: Phuoc Hung OJ Extended

Problem Statement

This package preserves the original task mechanism. Cho mảng độ dài nn. Mỗi phần tử bằng 00 nghĩa là chưa xác định, hoặc là một số trong [1,m][1,m]. Cần thay mọi số 00 sao cho hai phần tử kề nhau chênh lệch không quá 11. Hãy đếm số mảng hợp lệ.

Input

Dòng đầu chứa n,mn,m. Dòng hai chứa nn số.

Output

In số cách modulo 109+710^9+7.

Subtasks

  • Subtask 1 — 20 points: small data.
  • Subtask 2 — 30 points: medium data.
  • Subtask 3 — 50 points: full PHOJ package limits.

Examples

Input

3 5
2 0 2

Output

3

Explanation

The output follows directly from the rules above.