#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;

const int MOD = 1e9 + 7;
const int MAXN = 25005;
const int MAXK = 405;

int N, K, M, L, R;

long long res = 0;

int A[MAXN], f[MAXN][MAXK], g[MAXN][MAXK], a[MAXN][2], b[MAXN][2], fac[MAXK], invf[MAXK];

int qpow(int a, int b)
{
	int ret = 1;
	while (b)
	{
		if (b & 1) ret = (long long)ret * a % MOD;
		b >>= 1;
		a = (long long)a * a % MOD;
	}
	return ret;
}

inline void add(int &a, int b)
{
	a = (((long long)a + b) % MOD + MOD) % MOD;
}

void init()
{
	int cnt[MAXK], p;
	memset(cnt, 0, sizeof(cnt));
	p = 0;
	while (p < M && ++cnt[A[p + 1]] == 1)
		++p;
	f[0][p] = 1, L = p;
	memset(cnt, 0, sizeof(cnt));
	p = 0;
	while (p < M && ++cnt[A[M - p]] == 1)
		++p;
	g[0][p] = 1, R = p;
	fac[0] = 1;
	for (int i = 1; i <= K; i++)
		fac[i] = (long long)fac[i - 1] * i % MOD;
	for (int i = 0; i <= K; i++)
		invf[i] = qpow(fac[i], MOD - 2);
}

bool check()
{
	if (M < K)
		return 0;
	int cnt[MAXK], w = 0, ret = 0;
	memset(cnt, 0, sizeof(cnt));
	for (int i = 1; i <= K; i++)
	{
		cnt[A[i]]++;
		if (cnt[A[i]] == 1) w++;
		if (cnt[A[i]] == 2) w--;
	}
	ret |= (w == K);
	for (int i = K + 1; i <= M; i++)
	{
		cnt[A[i]]++, cnt[A[i - K]]--;
		if (cnt[A[i]] == 1) w++;
		if (cnt[A[i]] == 2) w--;
		if (cnt[A[i - K]] == 1) w++;
		if (cnt[A[i - K]] == 0) w--;
		ret |= (w == K);
	}
	return ret;
}

void DP1()
{
	res = (long long)(N - M + 1) * qpow(K, N - M) % MOD;
	f[1][1] = K;
	if (M == 1)
		g[1][1] = K;
	for (int i = 1; i < N; i++)
	{
		for (int j = 1; j < K; j++)
		{
			add(f[i + 1][j + 1], (long long)(K - j) * f[i][j] % MOD);
			add(f[i + 1][j + 2], -(long long)(K - j) * f[i][j] % MOD);
			add(f[i + 1][1], f[i][j]);
			add(f[i + 1][j + 1], -f[i][j]);
			add(g[i + 1][j + 1], (long long)(K - j) * g[i][j] % MOD);
			add(g[i + 1][j + 2], -(long long)(K - j) * g[i][j] % MOD);
			add(g[i + 1][1], g[i][j]);
			add(g[i + 1][j + 1], -g[i][j]);
		}
		for (int j = 2; j < K; j++)
			add(f[i + 1][j], f[i + 1][j - 1]), add(g[i + 1][j], g[i + 1][j - 1]);;
		for (int j = M; j < K; j++)
			add(g[i + 1][j], f[i + 1][j]);
	}
	int sum = 0;
	for (int j = 1; j < K; j++)
		add(sum, g[N][j]);
	sum = (long long)sum * fac[K - M] % MOD * invf[K] % MOD;
	res = (res - sum + MOD) % MOD;
}

void DP2()
{
	for (int i = 0; i < N - M; i++)
	{
		for (int j = 1; j < K; j++)
		{
			add(f[i + 1][j + 1], (long long)f[i][j] * (K - j) % MOD);
			add(f[i + 1][j + 2], 0 - (long long)f[i][j] * (K - j) % MOD);
			add(f[i + 1][1], f[i][j]);
			add(f[i + 1][j + 1], 0 - f[i][j]);
		}
		add(f[i + 1][K], (long long)f[i][K] * K % MOD);
		for (int j = 2; j <= K; j++)	
			add(f[i + 1][j], f[i + 1][j - 1]);
	}
	for (int i = 0; i < N - M; i++)
	{
		for (int j = 1; j < K; j++)
		{
			add(g[i + 1][j + 1], (long long)g[i][j] * (K - j) % MOD);
			add(g[i + 1][j + 2], 0 - (long long)g[i][j] * (K - j) % MOD);
			add(g[i + 1][1], g[i][j]);
			add(g[i + 1][j + 1], 0 - g[i][j]);
		}
		add(g[i + 1][K], (long long)g[i][K] * K % MOD);
		for (int j = 2; j <= K; j++)
			add(g[i + 1][j], g[i + 1][j - 1]);
	}
	for (int i = 0; i <= N - M; i++)
	{
		for (int j = 1; j < K; j++)
			add(a[i][0], f[i][j]);
		add(a[i][1], f[i][K]);
	}
	for (int i = 0; i <= N - M; i++)
	{
		for (int j = 1; j < K; j++)
			add(b[i][0], g[i][j]);
		add(b[i][1], g[i][K]);	
	}
	res = (long long)(N - M + 1) * qpow(K, N - M) % MOD;
	for (int i = 0; i <= N - M; i++)
	{
		long long x = a[i][0], y = a[i][1], u = b[N - M - i][0], v = b[N - M - i][1];
		res = (res - (x * u) % MOD + MOD) % MOD;
	}	
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> N >> K >> M;
	for (int i = 1; i <= M; i++)
		cin >> A[i];
	init();
	if (check())
		res = (long long)(N - M + 1) * qpow(K, N - M) % MOD;
	else if (L == M)
		DP1();
	else
		DP2();
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 79744