#include #define DIM 70 const int Mod = 1000000007; void copy_matrix(int d, long long A[][DIM], long long B[][DIM]) { int i, j; for (i = 0; i < d; i++) for (j = 0; j < d; j++) B[i][j] = A[i][j]; } void prod_matrix(int d, long long A[][DIM], long long B[][DIM], long long C[][DIM]) { int i, j, k; for (i = 0; i < d; i++) { for (j = 0; j < d; j++) { for (k = 0, C[i][j] = 0; k < d; k++) C[i][j] += A[i][k] * B[k][j] % Mod; C[i][j] %= Mod; } } } void pow_matrix(int d, long long A[][DIM], long long k, long long B[][DIM]) { int i, j; long long C[2][DIM][DIM], D[DIM][DIM]; copy_matrix(d, A, C[0]); for (i = 0; i < d; i++) for (j = 0; j < d; j++) B[i][j] = 0; for (i = 0; i < d; i++) B[i][i] = 1; for (i = 0, j = 1; k > 0; i ^= 1, j ^= 1, k >>= 1) { prod_matrix(d, C[i], C[i], C[j]); if (k % 2 == 1) { prod_matrix(d, B, C[i], D); copy_matrix(d, D, B); } } } int main() { long long L; int i, N, M, K, flag[11] = {}; scanf("%lld %d %d", &L, &N, &M); for (i = 1; i <= M; i++) { scanf("%d", &K); flag[K] = 1; } int j, k, ii, jj; long long A[DIM][DIM] = {}, B[DIM][DIM]; for (i = 1, j = 1; j <= N; j++, i += j) A[i][0] = 1; for (i = 1, j = 1, k = 1; 1; i++, k++) { if (k > j + 1) { j++; k = 1; if (j > N) break; } if (k != j) { for (ii = 1, jj = 1; jj <= N; jj++, ii += jj) if (jj != j) A[ii][i] = 1; } else A[DIM-1][i] = N - 1; if (k <= j) A[i+1][i] = 1; else A[i][i] = 1; } A[DIM-1][DIM-1] = N; long long ans = 0; pow_matrix(DIM, A, L, B); for (i = 1, j = 1, ans = B[DIM-1][0]; j <= N; j++, i += j + 1) if (flag[j] != 0) ans += B[i][0]; printf("%lld\n", ans % Mod); fflush(stdout); return 0; }