#include #include using namespace std; using namespace atcoder; using mint = modint1000000007; const int mod = 1000000007; //using mint = modint998244353; //const int mod = 998244353; //const int INF = 1e9; //const long long LINF = 1e18; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep2(i,l,r)for(int i=(l);i<(r);++i) #define rrep(i, n) for (int i = (n-1); i >= 0; --i) #define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i) #define all(x) (x).begin(),(x).end() #define allR(x) (x).rbegin(),(x).rend() #define endl "\n" #define P pair template inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; } vector> mul(vector>&A, vector>&B) { vector> C(A.size(), vector(B[0].size())); rep(i, A.size()) rep(j, B[0].size()) rep(k, A[0].size()) C[i][j] += A[i][k] * B[k][j]; return C; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); long long l; cin >> l; int n, m; cin >> n >> m; vectorv(n); rep(i, m) { int k; cin >> k; k--; v[k] = k + 1; } mapmp; rep(i, n) rep(j, v[i] + 1)mp[{i, j}] = mp.size(); int sz = mp.size(); vector> mans(sz, vector(sz)); rep(i, sz)mans[i][i] = 1; vector> mpow(sz, vector(sz)); rep(i, n) { rep(j, v[i] + 1) { int t = mp[{i, j}]; if (j != v[i]) { int s = mp[{i, j + 1}]; mpow[s][t] = 1; } else { int s = mp[{i, j}]; mpow[s][t] = 1; } if (j != v[i] - 1) { rep(k, n) { if (i == k)continue; int s = mp[{k, 0}]; mpow[s][t] = 1; } } } } mint ans = pow_mod(n, l, mod); l--; while (l > 0) { if (1 == l % 2) mans = mul(mpow, mans); l /= 2; mpow = mul(mpow, mpow); } rep(i, sz) { rep(j, n) ans -= mans[i][mp[{j, 0}]]; } rep(i, n) { if (0 == v[i])continue; rep(j, n) ans += mans[mp[{i, v[i] - 1}]][mp[{j, 0}]]; } cout << ans.val() << endl; return 0; }