#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const long long mod=1e9+7;
long long n,m,k,a[33333],cnt,fl,jc[33333],pdp[33333][555],ndp[33333][555],injc[33333],dp[33333][555],sum[33333][555],s[33333],ans[33333],ress,anss;
bool f[555];
long long sum0[33333][555],sum1[33333][555],fp[33333][555][2],res[33333][555][2],ad[333];
long long binpow(long long a,long long t)
{
	long long res=1ll,p=a;
	for (long long i=t;i;i>>=1)
	{
		if (i&1) res=res*p%mod;
		p=p*p%mod;
	}
	return res;
}
void Init()
{
	jc[0]=injc[0]=1;
	for (long long i=1;i<=n;i++)
	{
		jc[i]=jc[i-1]*i%mod;
		injc[i]=injc[i-1]*binpow(i,mod-2)%mod;
	}
}
long long C(long long n,long long k)
{
	return (jc[n]*injc[k]%mod)*injc[n-k]%mod;
}
int main()
{
	scanf("%lld%lld%lld",&n,&k,&m);
	Init();
	for (long long i=1;i<=m;i++) scanf("%lld",&a[i]);
	for (long long i=1;i<=m-k+1;i++)
	{
		memset(f,0,sizeof(f));
		cnt=0;
		for (long long j=i;j<i+k;j++)
		{
			if (!f[a[j]])
			{
				f[a[j]]=1;
				cnt++;
			}
		}
		if (cnt==k)
		{
			fl=1;
			break;
		}
	}
	if (fl)
	{
		printf("%lld\n",(n-m+1)*binpow(k,n-m)%mod);
		return 0;
	}
	memset(f,0ll,sizeof(f));
	cnt=0ll;
	for (long long i=m;i>=1;i--)
	{
		if (!f[a[i]])
		{
			f[a[i]]=1;
			cnt++;
		}
		else break;
	}
	if (cnt==m)
	{
		fp[0][0][0]=1;
		sum0[0][0]=1;
		for (int i=1;i<=n;i++)
		{
			for (int j=1;j<=k;j++)
			{
				if (j!=k) fp[i][j][0]=(sum0[i-1][j-1]+fp[i-1][j-1][0]*(k-j))%mod;
				fp[i][j][1]=(sum1[i-1][j-1]+fp[i-1][j-1][1]*(k-j))%mod;
			}
			fp[i][k][1]=(fp[i][k][1]+sum0[i-1][k-1])%mod;
			for (int j=k-1;j>=0;j--)
			{
				sum0[i][j]=(sum0[i][j+1]+fp[i][j][0])%mod;
			}
			for (int j=k;j>=0;j--)
			{
				sum1[i][j]=(sum1[i][j+1]+fp[i][j][1])%mod;
			}
		}
		memset(sum0,0,sizeof(sum0));
		memset(sum1,0,sizeof(sum1));
		for (int i=1;i<=n;i++)
		{
			for (int j=1;j<=k;j++)
			{
				if (j!=k)
				{
					res[i][j][0]=(sum0[i-1][j-1]+res[i-1][j-1][0]*(k-j))%mod;
					if (j>=m) res[i][j][0]=(res[i][j][0]+fp[i][j][0])%mod;
				}
				res[i][j][1]=(sum1[i-1][j-1]+res[i-1][j-1][1]*(k-j))%mod;
				if (j>=m) res[i][j][1]=(res[i][j][1]+fp[i][j][1])%mod;
			}
			res[i][k][1]=(res[i][k][1]+sum0[i-1][k-1])%mod;
			for (int j=k-1;j>=0;j--)
			{
				sum0[i][j]=(sum0[i][j+1]+res[i][j][0])%mod;
			}
			for (int j=k;j>=0;j--)
			{
				sum1[i][j]=(sum1[i][j+1]+res[i][j][1])%mod;
			}
		}
		/*for (int i=1;i<=n;i++)
		{
			for (int j=1;j<=k;j++)
			{
				cout<<res[i][j][0]<<" "<<res[i][j][1]<<endl;
			}
			cout<<endl;
		}*/
		for (int i=1;i<=k;i++)
		{
			anss=(anss+res[n][i][1])%mod;
		}
		anss=anss*binpow(jc[m],mod-2)%mod;
		anss=anss*binpow(C(k,m),mod-2)%mod;
		printf("%lld\n",anss);
		return 0;
	}
	dp[0][cnt]=1ll;
	for (long long i=0;i<=cnt;i++) sum[0][i]=1ll;
	for (long long i=1;i<=n;i++)
	{
		for (long long j=1;j<=k;j++)
		{
			dp[i][j]=(sum[i-1][j-1]+dp[i-1][j-1]*(k-j))%mod;
		}
		for (long long j=k-1;j>=0;j--)
		{
			sum[i][j]=(sum[i][j+1]+dp[i][j])%mod;
		}
	}
	for (long long i=1;i<=n;i++)
	{
		dp[i][k]=dp[i][k]*binpow(binpow(k,i),mod-2ll)%mod;
	}
	for (long long i=1;i<=n;i++)
	{
		s[i]=(s[i-1]+dp[i][k])%mod;
		ans[i]=s[i]*binpow(k,i)%mod;
		if (n-m-i>=0) ress=(ress+ans[i]*binpow(k,n-m-i))%mod;
	}
	memset(dp,0ll,sizeof(dp));
	memset(sum,0ll,sizeof(sum));
	memset(f,0ll,sizeof(f));
	memset(s,0ll,sizeof(s));
	cnt=0ll;
	for (long long i=1;i<=m;i++)
	{
		if (!f[a[i]])
		{
			f[a[i]]=1;
			cnt++;
		}
		else break;
	}
	dp[0][cnt]=1ll;
	for (long long i=0;i<=cnt;i++) sum[0][i]=1ll;
	for (long long i=1;i<=n;i++)
	{
		for (long long j=1;j<=k;j++)
		{
			dp[i][j]=(sum[i-1][j-1]+dp[i-1][j-1]*(k-j))%mod;
		}
		for (long long j=k-1;j>=0;j--)
		{
			sum[i][j]=(sum[i][j+1]+dp[i][j])%mod;
		}
	}
	for (long long i=1;i<=n;i++)
	{
		dp[i][k]=dp[i][k]*binpow(binpow(k,i),mod-2ll)%mod;
	}
	for (long long i=1;i<=n;i++)
	{
		s[i]=(s[i-1]+dp[i][k])%mod;
		anss=s[i]*binpow(k,i)%mod;
		if (n-m-i>=0) ress=(ress+anss*(binpow(k,n-m-i)-ans[n-m-i]))%mod;
	}
	if (ress<0ll) ress+=mod;
	printf("%lld\n",ress);
	return 0;
}

Measured memory_bytes: 729472