/*
Recall the definition of C(n,m) = the number of ways to pick m items from n indistinguishable ones.
In this problem, the order matters. So we must use C(n,m) * m!.
*/
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
int a[25001],cnt[401],dp1[25001][401],dp2[25001][401],combi[401][401],m,k,pwk[25001];
const int MOD=1000000007;
void madd(int &a,int b)
{
    a+=b;
    if (a>=MOD)
        a-=MOD;
}
void msubtract(int &a,int b)
{
    a-=b;
    if (a<0)
        a+=MOD;
}
long long qpow(long long a,int b)
{
    long long ret=1;
    for (;b;b>>=1,(a*=a)%=MOD)
        if (b&1)
            (ret*=a)%=MOD;
    return ret;
}
void calc(int len,int st,int dp[][401])
{
    dp[0][st]=1;
    for (int i=0;i<len;++i)
    {
        for (int j=0;j<=st+i&&j<k;++j)
            if (dp[i][j])
            {
                if (!j)
                {
                    madd(dp[i+1][1],dp[i][j]*k);
                    continue;
                }
                madd(dp[i+1][1],dp[i][j]);
                if (j+1<k)
                {
                    msubtract(dp[i+1][j+1],dp[i][j]);
                    madd(dp[i+1][j+1],(long long)dp[i][j]*(k-j)%MOD);
                    if (j+2<=st+i+1&&j+2<k)
                        msubtract(dp[i+1][j+2],(long long)dp[i][j]*(k-j)%MOD);
                }
            }
        for (int j=1;j<=st+i+1&&j<k;++j)
            madd(dp[i+1][j],dp[i+1][j-1]);
    }
}
int main()
{
    int n;
    scanf("%d%d%d",&n,&k,&m);
    for (int i=1;i<=m;++i)
        scanf("%d",a+i);
    pwk[0]=1;
    for (int i=1;i<=n-m;++i)
        pwk[i]=(long long)pwk[i-1]*k%MOD;
    int tot=(long long)pwk[n-m]*(n-m+1)%MOD;
    for (int i=1;i<=m-k+1;++i)
    {
        memset(cnt,0,sizeof(cnt));
        bool f=true;
        for (int j=i;f&&j<i+k;++j)
        {
            if (cnt[a[j]])
                f=false;
            ++cnt[a[j]];
        }
        if (f)
        {
            printf("%d\n",tot);
            return 0;
        }
    }
    memset(cnt,0,sizeof(cnt));
    bool onlyone=true;
    for (int i=1;onlyone&&i<=m;++i)
    {
        if (cnt[a[i]])
            onlyone=false;
        ++cnt[a[i]];
    }
    combi[0][0]=1;
    for (int i=1;i<=k;++i)
    {
        combi[i][0]=1;
        for (int j=1;j<=i;++j)
        {
            combi[i][j]=combi[i-1][j-1]+combi[i-1][j];
            if (combi[i][j]>=MOD)
                combi[i][j]-=MOD;
        }
    }
    if (onlyone)
    {
        calc(n,0,dp1);
        for (int i=0;i<n;++i)
        {
            for (int j=0;j<k&&j<=i;++j)
                if (dp2[i][j])
                {
                    madd(dp2[i+1][1],dp2[i][j]);
                    if (j+1<k)
                    {
                        msubtract(dp2[i+1][j+1],dp2[i][j]);
                        madd(dp2[i+1][j+1],(long long)dp2[i][j]*(k-j)%MOD);
                        if (j+2<=i+1&&j+2<k)
                            msubtract(dp2[i+1][j+2],(long long)dp2[i][j]*(k-j)%MOD);
                    }
                }
            for (int j=1;j<=i+1&&j<k;++j)
                madd(dp2[i+1][j],dp2[i+1][j-1]);
            for (int j=m;j<=i+1&&j<k;++j)
                madd(dp2[i+1][j],dp1[i+1][j]);
        }
        int occur=0;
        for (int i=1;i<k;++i)
            madd(occur,dp2[n][i]);
        occur=(long long)occur*qpow(combi[k][m],MOD-2)%MOD;
        for (int i=1;i<=m;++i)
            occur=(long long)occur*qpow(i,MOD-2)%MOD;
        msubtract(tot,occur);
        printf("%d\n",tot);
        return 0;
    }
    memset(cnt,0,sizeof(cnt));
    int leftdiff=0;
    while (!cnt[a[leftdiff+1]])
        ++cnt[a[++leftdiff]];
    memset(cnt,0,sizeof(cnt));
    int rightdiff=m+1;
    while (!cnt[a[rightdiff-1]])
        ++cnt[a[--rightdiff]];
    rightdiff=m-rightdiff+1;
    calc(n-m,leftdiff,dp1);
    calc(n-m,rightdiff,dp2);
    int sub=0;
    for (int leftlen=0;leftlen<=n-m;++leftlen)
    {
        int sum1=0,sum2=0;
        for (int i=1;i<k;++i)
        {
            madd(sum1,dp1[leftlen][i]);
            madd(sum2,dp2[n-m-leftlen][i]);
        }
        madd(sub,(long long)sum1*sum2%MOD);
    }
    msubtract(tot,sub);
    printf("%d\n",tot);
    return 0;
}


Measured memory_bytes: 79232