#include <bits/stdc++.h>

using namespace std;

const int max_n = 25555, max_k = 404, mod = 1000000007;

int mul(int x, int y) {
    return (1LL * x * y) % mod;
}

int power(int a, int b) {
    if (b == 0) {
        return 1;
    }
    if (b % 2 == 0) {
        return power(mul(a, a), b / 2);
    }
    return mul(a, power(a, b - 1));
}

int rev(int x) {
    return power(x, mod - 2);
}

int n, k, m, a[max_n];

void calc_dp(int dp[max_n][max_k], int cnt[max_n][max_k]) {
    for (int i = 1; i <= n; ++i) {
        int sum = 0, sum_cnt = 0;
        for (int j = k - 1; j > 0; --j) {
            sum += dp[i - 1][j];
            sum %= mod;
            sum_cnt += cnt[i - 1][j];
            sum_cnt %= mod;
            dp[i][j] = (mul(dp[i - 1][j - 1], k - j + 1) + sum) % mod;
            cnt[i][j] = (mul(cnt[i - 1][j - 1], k - j + 1) + sum_cnt) % mod;
            if (j >= m) {
                cnt[i][j] += dp[i][j];
                cnt[i][j] %= mod;
            }
        }
    }
}

bool is_colorful() {
    if (m < k) {
        return false;
    }
    bool used[max_k];
    for (int i = 0; i + k <= m; ++i) {
        memset(used, 0, sizeof(used));
        bool ok = true;
        for (int j = i; j < i + k; ++j) {
            if (used[a[j]]) {
                ok = false;
                break;
            }
            used[a[j]] = 1;
        }
        if (ok) {
            return true;
        }
    }
    return false;
}

int solve() {
    if (is_colorful()) {
        return 0;
    }
    set<int> all(a, a + m);
    int cnt[max_n][max_k];
    if (all.size() == m) {
        int dp[max_n][max_k];
        memset(dp, 0, sizeof(dp));
        memset(cnt, 0, sizeof(cnt));
        dp[0][0] = 1;
        calc_dp(dp, cnt);
        int res = 0;
        for (int i = 1; i < k; ++i) {
            res += cnt[n][i];
            res %= mod;
        }
        int d = 1;
        for (int i = k - m + 1; i <= k; ++i) {
            d = mul(d, i);
        }
        return mul(res, rev(d));
    }

    all.clear();
    for (int i = 0; i < m; ++i) {
        if (all.count(a[i])) {
            break;
        }
        all.insert(a[i]);
    }
    int cnt1 = all.size();
    all.clear();
    for (int i = m - 1; i >= 0; --i) {
        if (all.count(a[i])) {
            break;
        }
        all.insert(a[i]);
    }
    int cnt2 = all.size();

    int dp[2][max_n][max_k], res = 0;
    memset(dp, 0, sizeof(dp));
    dp[0][0][cnt1] = 1;
    dp[1][0][cnt2] = 1;
    calc_dp(dp[0], cnt);
    calc_dp(dp[1], cnt);
    for (int i = 0; i + m - 1 < n; ++i) {
        int c1 = i;
        int c2 = n - i - m;
        int sum1 = 0, sum2 = 0;
        for (int j = 1; j < k; ++j) {
            sum1 += dp[0][c1][j];
            sum2 += dp[1][c2][j];
            sum1 %= mod;
            sum2 %= mod;
        }
        res += mul(sum1, sum2);
        res %= mod;
    }
    return res;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> k >> m;
    for (int i = 0; i < m; ++i) {
        cin >> a[i];
    }
    int ans = mul(n - m + 1, power(k, n - m));
    ans += mod - solve();
    ans %= mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 121344