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;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<int>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define mem(a) memset((a),0,sizeof(a))
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
const int N=25005,K=405,mod=1e9+7;
ll f[N][K],g[N][K],ycl[N],ans;
int a[N],to[N],fr;
ll ksm(ll a,int b){
	int ans=1;
	for(;b;b>>=1){
		if(b&1)ans=ans*a%mod;
		a=a*a%mod;
	}
	return ans;
}
int main(){
	int n=read(),k=read(),m=read();
	For(i,1,m)a[i]=read(); int dq=0;
	For(i,1,m){dq++; if(to[a[i]])dq=min(dq,i-to[a[i]]); if(dq==k)fr=1; to[a[i]]=i;}
	f[0][dq]=1; 
	For(i,1,k)to[i]=n+1; dq=0;
	Rep(i,m,1){dq++; if(to[a[i]])dq=min(dq,to[a[i]]-i); if(dq==k)fr=1; to[a[i]]=i;}
	g[0][dq]=1;
	ans=n-m+1;
	For(i,1,n-m)ans=ans*k%mod; 
	if(dq<k&&dq==m){
		f[1][1]=k; 
		For(i,1,n){
			Rep(j,k-1,1){
				if(j>=m)g[i][j]=(g[i][j]+f[i][j])%mod;
				//cout<<i<<" "<<j<<" "<<f[i][j]<<" "<<g[i][j]<<endl;
				f[i+1][j]=(f[i][j]+f[i+1][j+1])%mod;
				g[i+1][j]=(g[i][j]+g[i+1][j+1])%mod;
			}
			For(j,1,k-1){
				if(j+1<k)f[i+1][j+1]=(f[i+1][j+1]+f[i][j]*(k-j))%mod;
				if(j+1<k)g[i+1][j+1]=(g[i+1][j+1]+g[i][j]*(k-j))%mod;
			}
		}
		ll sum=0;
		For(i,1,k-1)sum+=g[n][i]; //cout<<sum<<endl;
		sum%=mod;
		For(i,1,m)sum=sum*ksm(k-i+1,mod-2)%mod;
		cout<<(ans-sum+mod)%mod<<endl;
		return 0;
	}
	For(i,0,n-m-1){
		Rep(j,k-1,1){
			f[i+1][j]=(f[i][j]+f[i+1][j+1])%mod;
			g[i+1][j]=(g[i][j]+g[i+1][j+1])%mod;
		}
		For(j,1,k-1){
			if(j+1<k)f[i+1][j+1]=(f[i+1][j+1]+f[i][j]*(k-j))%mod;
			if(j+1<k)g[i+1][j+1]=(g[i+1][j+1]+g[i][j]*(k-j))%mod;
		}
	}
	if(!fr){
		For(i,1,n-m+1){
			ll sum0=0,sum1=0;
			For(j,1,k-1){
				sum0+=f[i-1][j];
				sum1+=g[n+1-i-m][j];
			}
			//cout<<sum0<<" "<<sum1<<endl;
			ans=(ans-sum0%mod*(sum1%mod))%mod;
		}	
	}
	cout<<(ans%mod+mod)%mod<<endl;
}