Problem: You are given integers N, K, and an integer sequence A of length M.

An integer sequence where each element is between 1 and K (inclusive) is said to be colorful when there exists a contiguous subsequence of length K of the sequence that contains one occurrence of each integer between 1 and K (inclusive).

For every colorful integer sequence of length N, count the number of the contiguous subsequences of that sequence which coincide with A, then find the sum of all the counts. Here, the answer can be extremely large, so find the sum modulo 10^9+7.

Constraints

* 1 \leq N \leq 25000
* 1 \leq K \leq 400
* 1 \leq M \leq N
* 1 \leq A_i \leq K
* All values in input are integers.

Input

Input is given from Standard Input in the following format:


N K M
A_1 A_2 ... A_M


Output

For every colorful integer sequence of length N, count the number of the contiguous subsequences of that sequence which coincide with A, then print the sum of all the counts modulo 10^9+7.

Examples

Input

3 2 1
1


Output

9


Input

4 2 2
1 2


Output

12


Input

7 4 5
1 2 3 1 2


Output

17


Input

5 4 3
1 1 1


Output

0


Input

10 3 5
1 1 2 3 3


Output

1458


Input

25000 400 4
3 7 31 127


Output

923966268


Input

9954 310 12
267 193 278 294 6 63 86 166 157 193 168 43


Output

979180369

Solution (in CPP):

Solution:
#include<bits/stdc++.h>
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
namespace io
{
	int F()
	{
		 int F=1,n=0;
		 char ch;
		 while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		 ch=='-'?F=0:n=ch-'0';
		 while((ch=getchar())>='0'&&ch<='9')n=n*10+ch-'0';
		 return F?n:-n;
	}
	long long G()
	{
		 long long F=1,n=0;
		 char ch;
		 while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		 ch=='-'?F=0:n=ch-'0';
		 while((ch=getchar())>='0'&&ch<='9')n=n*10+ch-'0';
		 return F?n:-n;
	}
}
int R(int l,int r)
{
	return (rand()<<15|rand())%(r-l+1)+l;
}
int a[25555];
const int M=1000000007;
int cnt[444];
int l[25005][404],r[25005][404];
int sl[25005][404],sr[25005][404];
int f[25005][404],g[25005][404];
int sf[25005][404],sg[25005][404];
int ex(int b,int e)
{
	int ans=1;
	for(;e;e>>=1,b=(long long)b*b%M)
		if(e&1)ans=(long long)ans*b%M;
	return ans;
}
int main()
{
	int n=io::F(),k=io::F(),m=io::F();
	for(register int i=1;i<=m;++i)a[i]=io::F();
	if(m>=k)
	{
		int tot=0;
		for(register int i=1;i<k;++i)
			if(cnt[a[i]]++==0)++tot;
		int fl=0;
		for(register int i=k;i<=m;++i)
		{
			if(cnt[a[i]]++==0)++tot;
			if(tot==k)fl=1;
			if(--cnt[a[i-k]]==0)--tot;
		}
		if(fl)
		{
			int ans=1;
			for(register int i=1;i<=n-m;++i)
				ans=ans*1ll*k%M;
			ans=1ll*ans*(n-m+1)%M;
			printf("%d\n",ans);
			return 0;
		}
		memset(cnt,0,sizeof(cnt));
	}
	for(register int i=1;i<=m;++i)++cnt[a[i]];
	int fl=0;
	for(register int i=1;i<=k;++i)
		if(cnt[i]>1)fl=1;
	if(fl)
	{
		memset(cnt,0,sizeof(cnt));
		int now=1;
		while(1)
		{
			if(cnt[a[now]])break;
			++cnt[a[now]];
			++now;
		}
		--now;
		l[0][now]=1;
		for(register int j=now;j;--j)
			sl[0][j]=1;
		
		memset(cnt,0,sizeof(cnt));
		now=0;
		while(1)
		{
			if(cnt[a[m-now]])break;
			++cnt[a[m-now]];
			++now;
		}
		r[0][now]=1;
		for(register int j=now;j;--j)
			sr[0][j]=1;
		
		for(register int i=1;i<=n-m;++i)
		{
			int *L=l[i],*R=r[i],*LL=l[i-1],*RR=r[i-1];
			int *SL=sl[i-1],*SR=sr[i-1];
			for(register int j=1;j<k;++j)
				L[j]=(1ll*LL[j-1]*(k-(j-1))+SL[j])%M,
				R[j]=(1ll*RR[j-1]*(k-(j-1))+SR[j])%M;
			L[k]=(1ll*k*LL[k]+LL[k-1])%M;
			R[k]=(1ll*k*RR[k]+RR[k-1])%M;
			SL=sl[i],SR=sr[i];
			for(register int j=k-1;j;--j)
				SL[j]=(SL[j+1]+L[j])%M,
				SR[j]=(SR[j+1]+R[j])%M;
		}
		
		int ans=0;
		for(register int i=0;i<=n-m;++i)
			ans=(ans+1ll*l[i][k]*sr[n-m-i][1]+1ll*sl[i][1]*r[n-m-i][k]+1ll*l[i][k]*r[n-m-i][k])%M;
		printf("%d\n",ans);
		return 0;
	}
	l[1][1]=sl[1][1]=k;
	if(m==1)r[1][1]=sr[1][1]=k;
	for(register int i=2;i<=n;++i)
	{
		int *L=l[i],*R=r[i],*LL=l[i-1],*RR=r[i-1];
		int *SL=sl[i-1],*SR=sr[i-1];
		int *F=f[i],*G=g[i],*FF=f[i-1],*GG=g[i-1];
		int *SF=sf[i-1],*SG=sg[i-1];
		for(register int j=1;j<k;++j)
			L[j]=(1ll*LL[j-1]*(k-(j-1))+SL[j])%M,
			R[j]=(1ll*RR[j-1]*(k-(j-1))+SR[j]+(j>=m)*L[j])%M;
		for(register int j=1;j<=k;++j)
			F[j]=(1ll*FF[j-1]*(k-(j-1))+SF[j])%M,
			G[j]=(1ll*(GG[j-1])*(k-(j-1))+SG[j]+(j>=m)*F[j])%M;
		F[k]=(F[k]+LL[k-1])%M;
		G[k]=(0ll+G[k]+RR[k-1]+LL[k-1])%M;
		SL=sl[i],SR=sr[i],SF=sf[i],SG=sg[i];
		for(register int j=k-1;j;--j)
			SL[j]=(SL[j+1]+L[j])%M,
			SR[j]=(SR[j+1]+R[j])%M;
		for(register int j=k;j;--j)
			SF[j]=(SF[j+1]+F[j])%M,
			SG[j]=(SG[j+1]+G[j])%M;
	}
	int ans=sg[n][1];
	for(register int i=1;i<=m;++i)
		ans=1ll*ans*ex(k+1-i,M-2)%M;
	printf("%d\n",ans);
	return 0;
}