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
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<setprecision(20)
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1e9+7;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
//llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int n,k;
bool toku=false;
vector<llint>solve(vector<int>in,int m){
	//スタート値を求める
	//実際にはなんかinはREVされてたりする
	vector<bool>use(k+1);
	int sta=0;
	for(auto it:in){
		if(use[it]){break;}
		use[it]=true;
		sta++;
	}
	vector<llint>ans(n-m+5);
	vector<llint>dp(k+1);
	dp[sta]=1;
	ans[0]=1;
	int h,i;
	for(h=1;h<=n-m+4;h++){
		vector<llint>ddp(k+1);
		for(i=k-1;i>0;i--){ddp[i]=ddp[i+1]+dp[i];}
		for(i=k-2;i>0;i--){ddp[i+1]+=dp[i]*(k-i);}
		for(i=1;i<k;i++){dp[i]=ddp[i]%mod;ans[h]+=dp[i];}
		ans[h]%=mod;
		//cout<<ans[h]<<endl;
	}
	return ans;
}
int main(void){
	llint i,j,m;cin>>n>>k>>m;
	if(n<k){cout<<0<<endl;return 0;}
	vector<int>a(m);
	for(i=0;i<m;i++){cin>>a[i];}
	//なんかカラフルでないやつをもとめて、イロイロする
	
	//なんかaの中でできちゃったやつを特殊処理します
	vector<int>kabu(k+1,-1);
	bool deki=false;
	int mae=-1;
	for(i=0;i<m;i++){
		maxeq(mae,kabu[a[i]]);
		kabu[a[i]]=i;
		if(i-mae>=k){deki=true;break;}
	}
	if(deki){
		llint kota=n-m+1;
		for(i=0;i<n-m;i++){kota*=k;kota%=mod;}
		cout<<kota<<endl;
		return 0;
	}
	
	
	auto hi=solve(a,m);
	REV(a);
	auto mg=solve(a,m);
	llint ans=0;
	llint mto=1;
	for(i=0;i<n-m;i++){mto*=k;mto%=mod;}
	for(i=0;i<=n-m;i++){
		ans+=mto;
		ans-=hi[i]*mg[n-m-i];
		ans%=mod;
	}
	ans+=mod;ans%=mod;
	//cerr<<ans<<endl;
	if(mae==-1){
		vector<int>in(k-1);
		for(i=0;i<k-1;i++){in[i]=i+1;}
		auto ret=solve(in,k-1);
		for(llint j=m+2;j<=k;j++){
			//cerr<<"in";
			llint hos=j-m-1;
			for(i=2;i<=k-m;i++){hos*=i;hos%=mod;}
			for(i=2;i<=k-j;i++){hos*=i;hos%=mod;}
			//if(n-k-k+j<0){cerr<<"d";break;}
			for(i=0;i<=n-k-k+j;i++){
				ans+=((ret[i]*ret[n-k-k+j-i])%mod)*hos;
				ans%=mod;
			}
		}
		//cerr<<hos<<endl;
		//for(auto it:ret){cerr<<it<<endl;}
	}
	cout<<ans<<endl;
	return 0;
}
