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>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,u) for(int i=start[u];i;i=e[i].next)
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
#define SZ(A) ((int)A.size())
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
inline int read()
{
	int s=0,f=1; char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')ch=getchar(),f=-1;
	while(isdigit(ch))s=s*10+ch-'0',ch=getchar();
	return ~f?s:-s;
}

const int maxn=25020;
const int mod=1e9+7;

int jc[maxn],jcn[maxn],inv[maxn];

inline void prepare()
{
	jc[0]=jc[1]=jcn[0]=jcn[1]=inv[1]=1;
	REP(i,2,25000)jc[i]=(ll)i*jc[i-1]%mod,inv[i]=(ll)(mod-mod/i)*inv[mod%i]%mod,jcn[i]=(ll)jcn[i-1]*inv[i]%mod;
}

inline int power(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)ans=(ll)ans*a%mod;
		b>>=1;
		a=(ll)a*a%mod;
	}
	return ans;
}

inline void pls(int &a,int b){ a+=b; a-=a>=mod?mod:0;}

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

int vis[maxn];
int type;

inline void init()
{
	n=read();k=read();m=read();
	REP(i,1,m)a[i]=read();
	REP(i,1,m-k+1)
	{
		static int vis[maxn];
		REP(j,1,k)vis[j]=0;
		REP(j,1,k)vis[a[i+j-1]]++;
		int flg=1;
		REP(j,1,k)if(vis[j]!=1){ flg=0;break;}
		if(flg)type=3;//allin
	}
	if(type!=3)
	{
		static int vis[maxn];
		REP(j,1,m)vis[a[j]]++;
		REP(j,1,k)if(vis[j]>1)type=2;
		if(!type)type=1;
	}
}

int ans;

inline void DP(int start,int *f)
{
	static int dp[maxn][420];
	memset(dp,0,sizeof(dp));
	dp[0][start]=1;
	f[0]=1;
	REP(i,1,n)
	{
		int sum=0;
		DREP(j,k-1,1)
		{
			sum=(sum+dp[i-1][j])%mod;
			dp[i][j]=(dp[i][j]+(ll)dp[i-1][j-1]*(k-j+1))%mod;
			dp[i][j]=(dp[i][j]+sum)%mod;
		}
	}
	REP(i,1,n)REP(j,1,k-1)f[i]=(f[i]+dp[i][j])%mod;
}

#define pii pair<int,int>

inline pii operator +(pii a,pii b){ pls(a.fi,b.fi); pls(a.se,b.se);return a;}
inline pii operator *(pii a,int b){ return mkr((ll)a.fi*b%mod,(ll)a.se*b%mod);}

inline void doing()
{
	if(type==3);
	else if(type==2)
	{
		static int vis[maxn],f[maxn],g[maxn];
		int L=1,R;
		for(L=1;!vis[a[L]];L++)vis[a[L]]=1;
		L--;
		memset(vis,0,sizeof(int)*(k+1));
		for(R=m;!vis[a[R]];R--)vis[a[R]]=1;
		R++;
		DP(L,f); DP(m-R+1,g);
		REP(i,0,n-m)ans=(ans+(ll)f[i]*g[n-m-i])%mod;
	}else
	{
		static pii dp[25020][420];
		dp[0][0]=mkr(1,0);
		REP(i,1,n)
		{
			pii sum=mkr(0,0);
			DREP(j,k-1,1)
			{
				sum=(sum+dp[i-1][j]);
				dp[i][j]=(dp[i][j]+dp[i-1][j-1]*(k-j+1));
				dp[i][j]=(dp[i][j]+sum);
			}
			REP(j,m,k-1)pls(dp[i][j].se,dp[i][j].fi);
		}
		pii sum=mkr(0,0);
		REP(j,1,k-1)sum=sum+dp[n][j];
		ans=(ll)sum.se*jcn[k]%mod*jc[k-m]%mod;
	}
	ans=((ll)power(k,n-m)*(n-m+1)-ans+mod)%mod;
	printf("%d\n",ans);
}

int main()
{
	prepare();
	init();
	doing();
	return 0;
}