#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;

LL power(LL a, int t)
{
	LL ret = 1;
	while(t > 0) {
		if(t & 1) ret = ret * a % MOD;
		a = a * a % MOD;
		t >>= 1;
	}
	return ret;
}

int n, m, k, a[25005];
LL rs[405];
LL dp0l[25005][405], dp0r[25005][405], totl[25005], totr[25005];
pair<LL, LL> dp1[25005][2][405];
bool hv[405];

void gen_dp0(LL cdp[][405], LL tot[])
{
	rep1(i, k) hv[i] = false;
	rep(i, m) {
		if(hv[a[i]]) {
			cdp[0][i] = 1;
			break;
		}
		hv[a[i]] = true;
	}
	rep1(i, n) {
		rs[0] = 0;
		rep(j, k) rs[j + 1] = rs[j] + cdp[i - 1][j];
		rep1(j, k) cdp[i][j] = (rs[k] - rs[j] + cdp[i - 1][j - 1] * (k - j + 1)) % MOD;
		tot[i] = (tot[i - 1] * k + cdp[i][k]) % MOD;
	}
}

void gen_dp1(pair<LL, LL> cdp[][2][405])
{
	cdp[0][0][0] = MP(1, 0);
	rep1(i, n) rep(b, 2) {
		rs[0] = 0;
		for(int j = 0; j <= k; j ++) rs[j + 1] = rs[j] + cdp[i - 1][b][j].first;
		rep1(j, k) cdp[i][b | (j == k)][j].first += (rs[k + 1] - rs[j] + cdp[i - 1][b][j - 1].first * (k - j + 1)) % MOD;
		rep1(j, k) cdp[i][b][j].first %= MOD;
	}
	rep1(i, n) rep(b, 2) {
		rs[0] = 0;
		for(int j = 0; j <= k; j ++) rs[j + 1] = rs[j] + cdp[i - 1][b][j].second;
		rep1(j, k) cdp[i][b | (j == k)][j].second += (rs[k + 1] - rs[j] + cdp[i - 1][b][j - 1].second * (k - j + 1)) % MOD;
		rep1(j, k) {
			if(j >= m) cdp[i][b][j].second += cdp[i][b][j].first;
			cdp[i][b][j].second %= MOD;
		}
	}
}

int main()
{
	scanf("%d%d%d", &n, &k, &m);
	rep(i, m) scanf("%d", &a[i]);
	rep(i, m - k + 1) {
		rep1(j, k) hv[j] = false;
		rep(j, k) hv[a[i + j]] = true;
		bool ok = true;
		rep1(j, k) if(!hv[j]) ok = false;
		if(ok) {
			printf("%lld\n", (n - m + 1) * power(k, n - m) % MOD);
			return 0;
		}
	}
	bool cc = false;
	rep1(i, k) hv[i] = false;
	rep(i, m) {
		if(hv[a[i]]) cc = true;
		hv[a[i]] = true;
	}
	LL ans = 0;
	if(cc) {
		gen_dp0(dp0l, totl);
		reverse(a, a + m);
		gen_dp0(dp0r, totr);
		for(int i = 0; i <= n - m; i ++)
		ans = (ans + totl[i] * power(k, n - m - i) + totr[n - m - i] * power(k, i) - totl[i] * totr[n - m - i]) % MOD;
	} else {
		gen_dp1(dp1);
		rep1(i, k) ans += dp1[n][1][i].second;
		ans %= MOD;
		for(int i = k; i > k - m; i --)
		ans = ans * power(i, MOD - 2) % MOD;
	}
	printf("%lld\n", (ans + MOD) % MOD);
	return 0;
}

Measured memory_bytes: 319744