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:
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 5121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
long long dp[25100][410][2];
long long sum[410][2];
int p[31000];
int cn[31000];
int t[31000];
int main(){
	int a,b,c;scanf("%d%d%d",&a,&b,&c);
	for(int i=0;i<c;i++){
		scanf("%d",p+i);
		p[i]--;
	}
	init_C(110000);
	int L=0;
	int R=0;
	for(int i=0;i<c;i++){
		if(t[p[i]]){
			break;
		}
		t[p[i]]=1;
		L++;
	}
	for(int i=0;i<b;i++){
		t[i]=0;
	}
	for(int i=c-1;i>=0;i--){
		if(t[p[i]]){
			break;
		}
		t[p[i]]=1;
		R++;
	}
	for(int i=0;i<=c-b;i++){
		for(int j=0;j<b;j++)cn[j]=0;
		bool ok=true;
		for(int j=0;j<b;j++){
			if(cn[p[i+j]])ok=false;
			cn[p[i+j]]++;
		}
		if(ok){
			printf("%lld\n",(a-c+1)*pw(b,a-c)%mod);
			return 0;
		}
	}
	dp[0][0][0]=1;
	for(int i=0;i<a;i++){
		for(int j=0;j<b;j++)for(int k=0;k<2;k++)sum[j][k]=0;
		for(int j=0;j<b;j++){
			for(int k=0;k<2;k++){
				if(!dp[i][j][k])continue;
				// printf("%d %d %d: %lld\n",i,j,k,dp[i][j][k]);
				if(j+1<b)dp[i+1][j+1][k]=(dp[i+1][j+1][k]+dp[i][j][k]*(b-j));
				if(k==0&&j+1<b&&j+1>=c)dp[i+1][j+1][1]=(dp[i+1][j+1][1]+dp[i][j][k]*(b-j))%mod;
				sum[j][k]=(sum[j][k]+dp[i][j][k])%mod;
			}
		}
		for(int k=0;k<2;k++){
			long long cur=0;
			for(int j=b-1;j>0;j--){
				cur=cur+sum[j][k];
				dp[i+1][j][k]=(dp[i+1][j][k]+cur)%mod;
				if(k==0&&j>=c){
					dp[i+1][j][1]=(dp[i+1][j][1]+cur)%mod;
				}
			}
		}
	}
	if(L==c){
		long long tmp=0;
		for(int i=0;i<b;i++)tmp=(tmp+dp[a][i][1])%mod;
		// printf("%lld\n",tmp);
		tmp=tmp*fact[b-c]%mod*finv[b]%mod;
		long long ret=(a-c+1)*pw(b,a-c);
		ret=(ret+mod-tmp)%mod;
		printf("%lld\n",ret);
		return 0;
	}else{
		long long ret=(a-c+1)*pw(b,a-c);
		for(int i=0;i<=a-c;i++){
			long long left=0;
			for(int j=L;j<b;j++){
				left=(left+dp[i+L][j][0])%mod;
			}
			left=left*fact[b-L]%mod*finv[b]%mod;
			long long right=0;
			for(int j=R;j<b;j++){
				right=(right+dp[(a-c-i)+R][j][0])%mod;
			}
			right=right*fact[b-R]%mod*finv[b]%mod;
			long long ks=left*right%mod;
			ret=(ret+mod-ks)%mod;
		}
		printf("%lld\n",ret);
	}
}