#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const ll MOD = TEN(9) + 7;
const int MX = 26000;
const int MK = 410;

ll inv[MX], fact[MX], ifact[MX];

void init() {
	inv[1] = 1;
	for (int i = 2; i < MX; ++i) {
		inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
	}
	fact[0] = ifact[0] = 1;
	for (int i = 1; i < MX; ++i) {
		fact[i] = fact[i-1] * i % MOD;
		ifact[i] = ifact[i-1] * inv[i] % MOD;
	}
}

ll comb(int n, int r) {
	if (n < 0 || r < 0 || r > n) return 0;
	return fact[n] * ifact[r] % MOD * ifact[n - r] % MOD;
}

ll dp[MX][MK]; //length, suffix
ll ac[MX][MK];
ll sm[MX][MK];

int main() {
	int N, K, M; cin >> N >> K >> M;
	vi A(M);

	rep(i, M) {
		cin >> A[i];
		--A[i];
	}

	init();
	dp[1][1] = K;
	for (int i = 1; i < MK; ++i) {
		ac[1][i] = K; 
	}

	for (int i = 2; i <= N; ++i) {
		for (int j = 1; j < K; ++j) {
			ll val = (dp[i-1][j-1] * (K-j+1) + ac[i-1][K] - ac[i-1][j-1]) % MOD;
			if (val < 0) val += MOD;
			dp[i][j] = val;
		}
		rep(j, MK-1) {
			ac[i][j+1] = (dp[i][j+1] + ac[i][j]) % MOD;
		} 
	}


	ll all = (N - M + 1);
	rep(i, N - M) all = all * K % MOD;

	for (int i = 0; i <= M - K; ++i) { // A : colorful
		vi ex(K);

		bool ok = true;
		for (int j = i; j < i + K; ++j) {
			if (ex[A[j]]) {
				ok = false;
				break;
			}
			ex[A[j]] = true;
		}

		if (ok) {
			cout << all << endl;
			return 0;
		}
	}

	int l, r;
	set<int> st;

	for (l = 0; l < M; ++l) {
		if (st.count(A[l])) {
			break;
		}
		st.insert(A[l]);
	}

	st.clear();
	for (r = 0; r < M; ++r) {
		if (st.count(A[M-1-r])) {
			break;
		}
		st.insert(A[M-1-r]);
	}

	if (l != M) { //contain same
		ll ng = 0;

		for (int i = 0; i <= N - M; ++i) {
			ll p = ac[i + l][min(i + l, K)] - ac[i + l][l - 1];
			if (p < 0) p += MOD;
			p = p * fact[K - l] % MOD * ifact[K] % MOD;

			int i2 = N - M - i;
			ll q = ac[i2 + r][min(i2 + r, K)] - ac[i2 + r][r - 1];
			if (q < 0) q += MOD;
			q = q * fact[K - r] % MOD * ifact[K] % MOD;

			ng = (ng + p * q) % MOD;
		}
		all -= ng;
		if (all < 0) all += MOD;
		cout << all << endl;
	} else { //distinct

		if (M == 1) {
			for (int i = 1; i < MK; ++i) {
				sm[1][i] = K; 
			}
		}

		for (int i = 2; i <= N; ++i) {
			for (int j = 1; j < K; ++j) {
				ll val = (j >= M ? dp[i][j] : 0) + (sm[i-1][j-1] - (j >= 2 ? sm[i-1][j-2] : 0)) * (K-j+1);
				val += sm[i-1][K] - sm[i-1][j-1];
				val %= MOD;
				if (val < 0) val += MOD;
				sm[i][j] = val;
			}

			rep(j, MK-1) {
				sm[i][j+1] = (sm[i][j+1] + sm[i][j]) % MOD;
			} 
		}

		ll ng = sm[N][K];

		ng = ng * fact[K - M] % MOD * ifact[K] % MOD;
		all -= ng;
		if (all < 0) all += MOD;
		cout << all << endl;		
	}

	return 0;
}