You are given integers N, K, and an integer sequence A of length M.

An integer sequence where each element is between 1 and K (inclusive) is said to be colorful when there exists a contiguous subsequence of length K of the sequence that contains one occurrence of each integer between 1 and K (inclusive).

For every colorful integer sequence of length N, count the number of the contiguous subsequences of that sequence which coincide with A, then find the sum of all the counts. Here, the answer can be extremely large, so find the sum modulo 10^9+7.

Constraints

* 1 \leq N \leq 25000
* 1 \leq K \leq 400
* 1 \leq M \leq N
* 1 \leq A_i \leq K
* All values in input are integers.

Input

Input is given from Standard Input in the following format:


N K M
A_1 A_2 ... A_M


Output

For every colorful integer sequence of length N, count the number of the contiguous subsequences of that sequence which coincide with A, then print the sum of all the counts modulo 10^9+7.

Examples

Input

3 2 1
1


Output

9


Input

4 2 2
1 2


Output

12


Input

7 4 5
1 2 3 1 2


Output

17


Input

5 4 3
1 1 1


Output

0


Input

10 3 5
1 1 2 3 3


Output

1458


Input

25000 400 4
3 7 31 127


Output

923966268


Input

9954 310 12
267 193 278 294 6 63 86 166 157 193 168 43


Output

979180369
#include <iostream>
#include <cstdint>
#include <vector>
#include <algorithm>

const uint32_t MOD = 1e9 + 7;
const uint32_t MAX_K = 404;
const uint32_t MAX_N = 2.5e4 + 10;

uint32_t n, k, m;
uint32_t seq[MAX_N];

void input() { 
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cin >> n >> k >> m;

	for (uint32_t i = 0;i < m;i++) {
		std::cin >> seq[i];
		seq[i]--;
	}
}

uint32_t fast_pow(uint32_t a, uint32_t b) {
	if (b == 0) {
		return 1;
	}
	uint64_t ans = fast_pow(a, b / 2);
	ans = ans * ans % MOD;
	if (b % 2) {
		ans = ans * a % MOD;
	}
	return ans;
}

uint64_t fact[MAX_K];
uint64_t iFact[MAX_K];

uint32_t prefLen, suffLen;
bool containsFull;

void precalc() {
	fact[0] = iFact[0] = 1;
	for (uint32_t i = 1;i < MAX_K;i++) {
		fact[i] = fact[i - 1] * i % MOD;
		iFact[i] = fast_pow(fact[i], MOD - 2);
	}
	std::vector<bool> found(k, false);
	prefLen = 0;
	for (uint32_t i = 0;i < m;i++) {
		if (!found[seq[i]]) {
			found[seq[i]] = true;
			prefLen++;
		} else {
			break;
		}
	}
	std::fill(found.begin(), found.end(), false);
	suffLen = 0;
	for (uint32_t i = m - 1;i < m;i--) {
		if (!found[seq[i]]) {
			found[seq[i]] = true;
			suffLen++;
		} else {
			break;
		}
	}

	std::vector<uint32_t> lastInd(k, m);
	uint32_t matchCnt = 0;
	for (uint32_t i = 0;i < m;i++) {
		if ((lastInd[seq[i]] == m) || (lastInd[seq[i]] < i - matchCnt)) {
			matchCnt++;
		} else {
			matchCnt = i - lastInd[seq[i]];
		}
		lastInd[seq[i]] = i;
		if (matchCnt == k) {
			containsFull = true;
			break;
		}
	}
	std::cerr << "prefLen " << prefLen << "\n";
	std::cerr << "suffLen " << suffLen << "\n";
	std::cerr << "contFull " << containsFull << "\n";
}

uint64_t comb(uint32_t n, uint32_t k) {
	return fact[n] * iFact[k] % MOD * iFact[n - k] % MOD;
}
uint64_t iComb(uint32_t n, uint32_t k) {
	return iFact[n] * fact[k] % MOD * fact[n - k] % MOD;
}

uint32_t dp[MAX_N][MAX_K];
uint32_t dpSum[MAX_N][MAX_K + 1];

//colorful sequences with length n, where the only colourful thing are the last
//k characters
uint32_t seqCnt[MAX_N];

void calc_dp_sum(uint32_t i) {
	dpSum[i][0] = 0;
	for (uint32_t j = 0;j < MAX_K;j++) {
		dpSum[i][j + 1] = (dpSum[i][j] + dp[i][j]) % MOD;
	}
}

uint64_t dp_sum(uint32_t i, uint32_t k1, uint32_t k2) {
	return (dpSum[i][k2 + 1] + MOD - dpSum[i][k1]) % MOD;
}

void calc_dp() {
	dp[0][0] = 1;
	calc_dp_sum(0);

	for (uint32_t i = 1;i <= n;i++) {
		for (uint32_t j = 1;j <= k;j++) {
			dp[i][j] += (uint64_t) (dp[i - 1][j - 1]) * (k - j + 1) % MOD;
			dp[i][j] += dp_sum(i - 1, j, k);
			dp[i][j] %= MOD;
		}
		seqCnt[i] = dp[i][k];
		dp[i][k] = 0;

		calc_dp_sum(i);
	}
}

uint32_t count_all() {
	uint64_t ans = fast_pow(k, n - m);
	ans = ans * (n - m + 1) % MOD;
	return ans;
}

uint32_t count_wrong_sep() {
	uint32_t ans = 0;
	for (uint32_t i = 0;i + m <= n;i++) {
		uint32_t fCnt = i + prefLen;
		uint32_t sCnt = n - i - m + suffLen;

		uint64_t curF = 0;
		for (uint32_t j = prefLen;j < k;j++) {
			curF += dp[fCnt][j];
		}

		curF %= MOD;
		curF = curF * fact[k - prefLen] % MOD;
		curF = curF * iFact[k] % MOD;

		uint64_t curS = 0;
		for (uint32_t j = suffLen;j < k ;j++) {
			curS += dp[sCnt][j];
		}
		curS %= MOD;
		curS = curS * fact[k - suffLen] % MOD;
		curS = curS * iFact[k] % MOD;

		ans += curS * curF % MOD;
		ans %= MOD;
	}
	return ans;
}

uint32_t solve_whole() {
	uint64_t wrongCnt = 0;
	for (uint32_t i = 0;i + m <= n;i++) {
		uint32_t fCnt = i + m;
		for (uint32_t j = m;j <= k;j++) {
			uint32_t sCnt = n + j - i - m;
			if (sCnt > n) {
				continue;
			}
			uint64_t cur = dp[fCnt][j];

			cur = cur * iFact[k] % MOD * fact[k - m] % MOD;
			cur = cur * iFact[k] % MOD * fact[k - j] % MOD;

			cur = cur * dp_sum(sCnt, j, k) % MOD;;

			wrongCnt += cur;
			wrongCnt %= MOD;
		}
	}

	uint64_t ans = (count_all() + MOD - wrongCnt) % MOD;
	return ans;
}


uint32_t solve_sep() {
	return (count_all() + MOD - count_wrong_sep()) % MOD;
}

int main() {
	input();
	precalc();
	calc_dp();

	uint32_t ans;
	if (containsFull) {
		ans = count_all();
	} else if (prefLen == m) {
		ans = solve_whole();
	} else {
		ans = solve_sep();
	}
	std::cout << ans << "\n";
}


