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 <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
template<unsigned int mod_>
struct ModInt{
	using uint = unsigned int;
	using ll = long long;
	using ull = unsigned long long;

	constexpr static uint mod = mod_;

	uint v;
	ModInt():v(0){}
	ModInt(ll v):v(normS(v%mod+mod)){}
	explicit operator bool() const {return v!=0;}
	static uint normS(const uint &x){return (x<mod)?x:x-mod;}		// [0 , 2*mod-1] -> [0 , mod-1]
	static ModInt make(const uint &x){ModInt m; m.v=x; return m;}
	ModInt operator+(const ModInt& b) const { return make(normS(v+b.v));}
	ModInt operator-(const ModInt& b) const { return make(normS(v+mod-b.v));}
	ModInt operator-() const { return make(normS(mod-v)); }
	ModInt operator*(const ModInt& b) const { return make((ull)v*b.v%mod);}
	ModInt operator/(const ModInt& b) const { return *this*b.inv();}
	ModInt& operator+=(const ModInt& b){ return *this=*this+b;}
	ModInt& operator-=(const ModInt& b){ return *this=*this-b;}
	ModInt& operator*=(const ModInt& b){ return *this=*this*b;}
	ModInt& operator/=(const ModInt& b){ return *this=*this/b;}
	ll extgcd(ll a,ll b,ll &x,ll &y) const{
		ll u[]={a,1,0},v[]={b,0,1};
		while(*v){
			ll t=*u/ *v;
			rep(i,3) swap(u[i]-=t*v[i],v[i]);
		}
		if(u[0]<0) rep(i,3) u[i]=-u[i];
		x=u[1],y=u[2];
		return u[0];
	}
	ModInt inv() const{
		ll x,y;
		extgcd(v,mod,x,y);
		return make(normS(x+mod));
	}
	bool operator==(const ModInt& b) const { return v==b.v;}
	bool operator!=(const ModInt& b) const { return v!=b.v;}
	friend istream& operator>>(istream &o,ModInt& x){
		ll tmp;
		o>>tmp;
		x=ModInt(tmp);
		return o;
	}
	friend ostream& operator<<(ostream &o,const ModInt& x){ return o<<x.v;}
};
using mint = ModInt<1000000007>;

int N,K,M;
vector<int> a;
vector<mint> calc1(){
	vector<mint> dp(K);
	{
		set<int> st;
		rep(i,M){
			if(st.count(a[M-1-i])){
				dp[i] = 1;
				break;
			}
			st.insert(a[M-1-i]);
		}
	}

	vector<mint> res(N-M+1);
	res[0] = 1;
	rep(i,N-M){
//		show(dp);
		vector<mint> dif(K+2);
		rep(k,K){
			dif[1] += dp[k];
			dif[k+1] -= dp[k];
			dif[k+1] += dp[k]*(K-k);
			dif[k+2] -= dp[k]*(K-k);
		}
		rep1(k,K-1){
			dp[k] = dp[k-1] + dif[k];
		}
		rep(k,K) res[i+1] += dp[k];
	}
	return res;
}
mint solve1(){	//non-unique
	vector<mint> x = calc1();
	reverse(all(a));
	vector<mint> y = calc1();
//	show(x);
//	show(y);
	mint ans = 0;
	mint Kex = 1;
	rep(i,N-M) Kex *= K;
	rep(i,N-M+1){
		int j = N-M-i;
		ans += Kex-x[i]*y[j];
	}
	return ans;
}
bool uniq(){
	set<int> st;
	rep(i,M) st.insert(a[i]);
	return (int)st.size() == M;
}
int oknum;
vector<int> cnt;
void ad(int c){
	if(cnt[c]==1) oknum--;
	cnt[c]++;
	if(cnt[c]==1) oknum++;
}
void er(int c){
	if(cnt[c]==1) oknum--;
	cnt[c]--;
	if(cnt[c]==1) oknum++;
}

bool hascolorful(){
	if(M<K) return 0;
	cnt.resize(K);
	rep(i,K) ad(a[i]);
	if(oknum==K) return 1;
	rep(i,M-K){
		ad(a[K+i]);
		er(a[i]);
		if(oknum==K) return 1;
	}
	return 0;
}
mint solve2(){
	vector<vector<mint>> dp(K,vector<mint>(2));
	dp[0][0] = 1;

	rep(i,N){
		vector<vector<mint>> dif(K+2,vector<mint>(2));
		rep(t,2){
			rep(k,K){
				dif[1][t] += dp[k][t];
				dif[k+1][t] -= dp[k][t];
				dif[k+1][t] += dp[k][t]*(K-k);
				dif[k+2][t] -= dp[k][t]*(K-k);
			}
			rep(k,K){
				dp[k][t] = (k==0?0:dp[k-1][t]) + dif[k][t];
			}
		}
		for(int k=M;k<K;k++) dp[k][1] += dp[k][0];
	}

	mint res = 0;
	rep(i,K) res += dp[i][1];
	rep(i,M) res /= K-i;

	mint Kex = 1;
	rep(i,N-M) Kex *= K;

	res = Kex*(N-M+1) - res;
	return res;
}

int main(){
	cin>>N>>K>>M;
	a.resize(M);
	rep(i,M){
		cin>>a[i];
		a[i]--;
	}
	if(hascolorful()){
		mint ans = N-M+1;
		rep(i,N-M) ans *= K;
		cout<<ans<<endl;
		return 0;
	}
	if(!uniq()) cout<<solve1()<<endl;
	else cout<<solve2()<<endl;
}
