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:
// oh, the less I know the better
// corner cases // int vs ll // cin vs scanf // clear structures // statement // doublesz
#include <bits/stdc++.h>
//#define endl '\n'
#define fst first
#define snd second
#define pb push_back
#define sz(x) int(x.size())
#define REP(i,n) for(int i = 0; i < int(n); ++i)
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
const int N = 25100, K = 410;

template<typename T, T mod>
struct Tint{
	T val;
	Tint(): val(0){}
	Tint(long long x){ x %= mod; if(x < 0) x += mod; val = x; }
	// basic operations
	Tint& operator += (Tint oth){ val += oth.val; if(val >= mod) val -= mod; return *this; }
	Tint& operator -= (Tint oth){ val -= oth.val; if(val < 0) val += mod; return *this; }
	Tint& operator *= (Tint oth){ val = (long long)(val) * oth.val % mod; return *this; }
	Tint operator + (Tint oth) const{ return Tint(*this) += oth; }
	Tint operator - (Tint oth) const{ return Tint(*this) -= oth; }
	Tint operator * (Tint oth) const{ return Tint(*this) *= oth; }
};

// usage
const ll MOD = 1e9+7;
using Mint = Tint<int,MOD>;

int k;

Mint bpow(Mint x, long long p){
	Mint ans;
	for(ans = 1; p; p >>= 1, x = x*x)
		if(p&1) ans = ans * x;
	return ans;
}

bool colorful(vector<int> a){
	set<int> s;
	deque<int> dq;
	for(int x : a){
		if(s.count(x)){
			while(dq.front() != x){ 
				s.erase(dq.front());
				dq.pop_front();
			}
			dq.pop_front();
		}
		s.insert(x);
		dq.push_back(x);
		if(sz(dq) == k) return true;
	}
	return false;
}

int process(vector<int> a){
	set<int> s;
	deque<int> dq;
	for(int x : a){
		if(s.count(x)){
			while(dq.front() != x){
				s.erase(dq.front());
				dq.pop_front();
			}
			dq.pop_front();
		}
		s.insert(x);
		dq.push_back(x);
	}
	return sz(dq);
}

vector<Mint> get(int x){
	vector< vector<Mint> > dp(N,vector<Mint>(k+1));
	dp[0][x] = 1;
	for(int i = 0; i+1 < N; ++i){
		Mint psum;
		for(int j = k-1; j >= 1; --j){
			psum += dp[i][j];
			dp[i+1][j] += psum;
		}
		for(int j = 1; j+1 < k; ++j){
			dp[i+1][j+1] += dp[i][j] * (k-j);
		}
	}
	vector<Mint> ans(N);
	for(int i = 0; i < N; ++i){
		for(int j = 0; j < k; ++j){
			ans[i] += dp[i][j];
		}
	}
	return ans;
}

Mint get2(int m, int n){
	vector< vector< vector<Mint> > > dp(N);
	for(auto &t : dp){
		t.resize(2);
		for(auto &q : t) q.resize(K);
	}
	dp[1][0][1] = k;
	if(m == 1) dp[1][1][1] = k;
	for(int i = 1; i <= n; ++i){
		for(int t = 0; t < 2; ++t){
			for(int c = k-1; c >= 1; --c){
				dp[i][t][c] += dp[i][t][c+1];
				dp[i+1][t][c] = dp[i][t][c];
				dp[i+1][t][c] += dp[i][t][c-1] * (k-c+1);
			}
		}
		for(int c = m; c < k; ++c){
			dp[i+1][1][c] += dp[i+1][0][c];
		}
	}
	return dp[n][1][1];
}

Mint fact[N], ifact[N];

void build_fact(){
	fact[0] = ifact[0] = 1;
	for(int i = 1; i < N; ++i){
		fact[i] = fact[i-1] * i;
		ifact[i] = bpow(fact[i],MOD-2);
	}
}

int main(){

	fastio;
	//cout << "ok" << endl;
	build_fact();
	int n,m;
	cin >> n >> k >> m;
	vector<int> a(m);
	REP(i,m) cin >> a[i];
	//cout << "Se lesho como un campeon" << endl;

	Mint ans = Mint(n-m+1) * bpow(k,n-m);
	//cout << "ok" << endl;
	if(colorful(a)){
		cout << ans.val << endl;
		exit(0);
	}
	//cout << "Not colorful" << endl;
	set<int> s;
	for(int x : a) s.insert(x);
	if(sz(a) != sz(s)){
		int x = process(a);
		reverse(a.begin(),a.end());
		int y = process(a);
		Mint res = 0;
		vector<Mint> vx = get(x);
		vector<Mint> vy = get(y);
		for(int i = 0; i <= n-m; ++i){
			res += vx[i] * vy[n-m-i];
		}
		ans -= res;
	}else{
		Mint res = get2(m,n);
		res *= ifact[k];
		res *= fact[k-m];
		ans -= res;
	}

	cout << ans.val << endl;

	return 0;
}