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
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c<=32)c=_buff.get();return c;}
ll qpow(ll x,ll k){return k==0?1:1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
int n,m,K;
int a[25111],pw[25111];
bool hs[411];
inline void upd(int &x,int v){x=x+v>=mod?x+v-mod:x+v;}
void calc_dp(int dp[25111][411],int S)
{
	for(int i=0;i<=n;i++)for(int j=0;j<=K;j++)dp[i][j]=0;
	dp[0][S]=1;
	for(int i=0;i<=n;i++)
	{
		int tmp=0;
		for(int j=K-1;j>=0;j--)
		{
			upd(dp[i+1][j+1],1ll*dp[i][j]*(K-j)%mod);
			upd(tmp,dp[i][j]);
			if(j>0)upd(dp[i+1][j],tmp);
		}
		upd(dp[i+1][K],1ll*dp[i][K]*K%mod);
	}
}
int dp0[25111][411],dp1[25111][411],dp2[25111][2][411];
int dps[25111][2][411];
void calc_dp2()
{
	dp2[0][0][0]=1;
	for(int i=0;i<=n;i++)
	{
		for(int t=0;t<2;t++)
		{
			int tmp=0;
			for(int j=K;j>=0;j--)
			{
				if(j<K)upd(dp2[i+1][t|((j+1)>=K)][j+1],1ll*dp2[i][t][j]*(K-j)%mod);
				upd(tmp,dp2[i][t][j]);
				if(j>0)upd(dp2[i+1][t|(j>=K)][j],tmp);
			}
		}
	}
	memset(dps,0,sizeof(dps));
	for(int i=0;i<=n;i++)
	{
		for(int t=0;t<2;t++)
		{
			int tmp=0;
			for(int j=K;j>=0;j--)
			{
				if(j>=m)upd(dps[i][t][j],dp2[i][t][j]);
				if(j<K)upd(dps[i+1][t|((j+1)>=K)][j+1],1ll*dps[i][t][j]*(K-j)%mod);
				upd(tmp,dps[i][t][j]);
				if(j>0)upd(dps[i+1][t|(j>=K)][j],tmp);
			}
		}
	}
	
}
int main()
{
	getiii(n,K,m);
	for(int i=1;i<=m;i++)geti(a[i]);
	pw[0]=1;
	for(int i=1;i<=n;i++)pw[i]=1ll*pw[i-1]*K%mod;
	bool has=0;
	for(int i=1;i<=m-K+1;i++)
	{
		bool f=1;
		memset(hs,0,sizeof(hs));
		for(int j=0;j<K;j++)
		{
			f&=hs[a[i+j]]==0;
			hs[a[i+j]]=1;
		}
		if(f)has=1;
	}
	if(has)
	{
		cout<<1ll*qpow(K,n-m)*(n-m+1)%mod;
		return 0;
	}
	int l0=-1,l1=-1;
	memset(hs,0,sizeof(hs));
	for(int i=1;i<=m;i++)
	{
		if(hs[a[i]])
		{
			l0=i-1;
			break;
		}
		hs[a[i]]=1;
	}
	memset(hs,0,sizeof(hs));
	for(int i=m;i>=1;i--)
	{
		if(hs[a[i]])
		{
			l1=m-i;
			break;
		}
		hs[a[i]]=1;
	}
	int ans=0;
	if(l0!=-1)
	{
		calc_dp(dp0,l0);
		calc_dp(dp1,l1);
		for(int i=1;i<=n-m+1;i++)
		{
			int m0=i-1,m1=n-(i+m-1);
			upd(ans,(pw[n-m]-1ll*(pw[m0]-dp0[m0][K]+mod)*(pw[m1]-dp1[m1][K]+mod)%mod+mod)%mod);
		}
	}
	else
	{
		calc_dp2();
		for(int i=0;i<=K;i++)upd(ans,dps[n][1][i]);
		int coef=1;
		for(int i=1;i<=m;i++)coef=1ll*coef*(K-i+1)%mod;
		ans=1ll*ans*qpow(coef,mod-2)%mod;
	}
	cout<<(ans%mod+mod)%mod<<endl;
	return 0;
}
