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>
#define For(i,l,r) for(int i = (l),i##end = (r);i <= i##end;i++)
#define Fordown(i,r,l) for(int i = (r),i##end = (l);i >= i##end;i--)
#define debug(x) cout << #x << " = " << x << endl

using namespace std;

typedef long long ll;

template <typename T> inline bool chkmin(T &x,T y) { return y < x ? x = y,1 : 0; }
template <typename T> inline bool chkmax(T &x,T y) { return x < y ? x = y,1 : 0; }

const int INF = 0x3f3f3f3f;
const int N = 25000 + 10,K = 400 + 10,mod = 1e9 + 7;

int a[N],vis[N];

int n,k,m;

inline int read() {
	int x = 0,flag = 1;
	char ch = getchar();
	while(!isdigit(ch) && ch != '-')ch = getchar();
	if(ch == '-')flag = -1,ch = getchar();
	while(isdigit(ch))x = (x << 3) + (x << 1) + (ch - '0'),ch = getchar();
	return x * flag;
}

inline int fpm(int Bs,int b) {
	int res = 1;
	while(b) {
		if(b & 1) res = 1ll * res * Bs % mod;
		Bs = 1ll * Bs * Bs % mod,b /= 2;
	}
	return res;
}
inline int Mod(int val) {
	if(val >= mod) val -= mod;
	if(val < 0) val += mod;
	return val;
}

namespace Case1 {
	int L[N],R[N],V[N],dp[N][K],Sum[N][K];
	inline void Dp(int A[],int cnt) {
		memset(dp,0,sizeof(dp)),memset(Sum,0,sizeof(Sum));
		dp[0][cnt] = 1;
		For(i,0,cnt) Sum[0][i] = 1;
		For(i,1,n) {
			Fordown(j,k - 1,1) {
				dp[i][j] = (Sum[i - 1][j] + 1ll * dp[i - 1][j - 1] * (k - j + 1)) % mod;
				Sum[i][j] = Mod(Sum[i][j + 1] + dp[i][j]);
			}
			Sum[i][0] = Sum[i][1];
		}
		For(i,0,n) A[i] = Sum[i][0];
	}
	inline int Solve() {
		int posl = m,posr = m;
		For(i,1,m) {
			if(V[a[i]]) { posl = i - 1;break; }
			V[a[i]] = true;
		}
		For(i,1,k) V[i] = false;
		Fordown(i,m,1) {
			if(V[a[i]]) { posr = m - i;break; }
			V[a[i]] = true;
		}
		int Sign = 1;
		For(i,1,m - k + 1) {
			For(j,1,k) V[j] = false;
			For(j,i,i + k - 1) V[a[j]] = true;
			bool flag = true;
			For(j,1,k) if(!V[j]) flag = false;
			if(flag) { Sign = 0;break; }
		}
		Dp(L,posl),Dp(R,posr);
		int ans = 0;
		For(i,1,n - m + 1)
			ans = (ans + fpm(k,n - m) - 1ll * Sign * L[i - 1] * R[n - i - m + 1]) % mod;
		return (ans + mod) % mod;
	}
}
namespace Case2 {
	int Ans[N],dp[N][K][2],Sum[N][K][2],tot[N][K][2],Stot[N][K][2];
	inline int Dp() {
		dp[0][0][0] = Sum[0][0][0] = 1;
		For(i,1,n) {
			For(l,0,1) {
				dp[i][k][1] = (dp[i][k][1] + Sum[i - 1][k - 1][l]) % mod;
				tot[i][k][1] = (1ll * tot[i][k][1] + Stot[i - 1][k - 1][l] + Sum[i - 1][k - 1][l]) % mod;
				Sum[i][k][1] = dp[i][k][1],Stot[i][k][1] = tot[i][k][1];
			}
			Fordown(j,k - 1,1) For(l,0,1) {
				dp[i][j][l] = (Sum[i - 1][j][l] + 1ll * dp[i - 1][j - 1][l] * (k - j + 1)) % mod;
				tot[i][j][l] = (Stot[i - 1][j][l] + 1ll * tot[i - 1][j - 1][l] * (k - j + 1) + (j >= m ? dp[i][j][l] : 0)) % mod;
				Sum[i][j][l] = Mod(Sum[i][j + 1][l] + dp[i][j][l]);
				Stot[i][j][l] = Mod(Stot[i][j + 1][l] + tot[i][j][l]);
			}
			For(l,0,1) {
				Sum[i][0][l] = Sum[i][1][l];
				Stot[i][0][l] = Stot[i][1][l];
			}
		}
		return Stot[n][0][1];
	}
	inline int Solve() {
		int prod = 1;
		For(i,k - m + 1,k) prod = 1ll * prod * i % mod;
		int ans = 1ll * Dp() * fpm(prod,mod - 2) % mod;
		return ans;
	}
}

int main() {

	n = read(),k = read(),m = read();
	bool flag = false;
	For(i,1,m) {
		a[i] = read();
		if(vis[a[i]]) flag = true;
		vis[a[i]] = true;
	}
	if(flag) printf("%d\n",Case1 :: Solve());
	else printf("%d\n",Case2 :: Solve());

	return 0;
}