#include <bits/stdc++.h>

using namespace std;
#pragma GCC optimize("O3")

typedef long long ll;
typedef long double ld;
int lst;
int sz = 0;
const int mod = (int)1e9 + 7;
int sum(int a, int b) {
    int s = a + b;
    if (s >= mod) s -= mod;
    return s;
}
int mult(int a, int b) {
    return (1LL * a * b) % mod;
}
int sub(int a, int b) {
    int s = a - b;
    if (s < 0) s += mod;
    return s;
}
const int maxN = 25000 + 10;
const int maxK = 405;
int dp[maxN][maxK];
int pwk[maxN];
int a[maxN];
int other_dp[maxN][maxK];
int cnt[maxK];
int n, k, m;
int main() {
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> k >> m;
    for (int i = 1; i <= m; i++) {
        cin >> a[i];
    }
    pwk[0] = 1;
    for (int i = 1; i <= n; i++) {
        pwk[i] = mult(k, pwk[i - 1]);
    }
    for (int y = 1; y <= k - 1; y++) {
        dp[0][y] = 1;
    }
    for (int x = 1; x <= n; x++) {
        int pref_sum = 0;
        for (int y = 1; x + y <= n && y < k; y++) {
            pref_sum = sum(pref_sum, dp[x - 1][y]);
            dp[x][y] = pref_sum;
            if (y + 1 < k) {
                dp[x][y] = sum(dp[x][y], mult(k - y, dp[x - 1][y + 1]));
            }
        }
    }
    for (int i = 0; i <= n; i++) {
        int pref_sum = 0;
        for (int j = 1; j + i <= n && j < k; j++) {
            if (i == 0) {
                other_dp[i][j] = dp[n - j][j];
                continue;
            }
            pref_sum = sum(pref_sum, dp[i - 1][j]);
            if (j + 1 < k) {
                other_dp[i][j] = sum(other_dp[i][j], mult(other_dp[i - 1][j + 1], k - j));
            }
            other_dp[i][j] = sum(other_dp[i][j], mult(pref_sum, dp[n - i - j][j]));
        }
    }
    bool has = false;
    for (int i = 1; i + k - 1 <= m; i++) {
        bool ok = true;
        memset(cnt, 0, sizeof cnt);
        for (int j = i; j <= i + k - 1; j++) {
            if (cnt[a[j]]) {
                ok = false;
                break;
            }
            cnt[a[j]]++;
        }
        if (ok) has = true;
    }
    if (has) {
        int ans = 0;
        for (int i = 1; i + m - 1 <= n; i++) {
            ans = sum(ans, pwk[n - m]);
        }
        cout << ans;
        return 0;
    }
    memset(cnt, 0, sizeof cnt);
    int len = -1;
    for (int i = 1; i <= m; i++) {
        if (cnt[a[i]] > 0) {
            len = i - 1;
            break;
        }
        cnt[a[i]]++;
    }
    if (len == -1) len = m;
    if (len == m) {
        assert(m < k);
        int ans = 0;
        for (int i = 1; i + m - 1 <= n; i++) {
            ans = sum(ans, sub(pwk[n - m], other_dp[i - 1][m]));
        }
        cout << ans;
        return 0;
    }
    int len2 = -1;
    memset(cnt, 0, sizeof cnt);
    for (int i = m; i >= 1; i--) {
        if (cnt[a[i]] > 0) {
            len2 = m - i;
            break;
        }
        cnt[a[i]]++;
    }
    assert(len2 != -1);
    int ans = 0;
    for (int i = 1; i + m - 1 <= n; i++) {
       // cout << dp[i - 1][len] << " " << (i - 1) << " hi " << len << endl;;
        ans = sum(ans, sub(pwk[n - m], mult(dp[i - 1][len], dp[n - (i + m - 1)][len2])));
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 79616