#include <bits/stdc++.h>
using namespace std;
const int maxn = 10001, mo = 1000000000 + 7;
int n, m, T;
int cho[10][maxn], mod[maxn], cnt[maxn];
int dfs(int rank, int last, long long delta) {
  int i, j;
  int ans = delta;
  if (rank <= 6)
    for (i = last + 1; i <= m / 2; ++i)
      if (!cho[rank][i]) {
        if (rank <= 5) {
          for (j = 0; j < m; ++j) cho[rank + 1][j] = false;
          for (j = 0; j < m; ++j)
            if (cho[rank][j])
              cho[rank + 1][j] = cho[rank + 1][mod[j + i]] =
                  cho[rank + 1][mod[j - i + m]] = true;
        }
        ans += dfs(rank + 1, i, delta * cnt[i] % mo);
        if (ans >= mo) ans -= mo;
      }
  return ans;
}
int main() {
  int i, j;
  int ans;
  scanf("%d%d%d", &n, &m, &T);
  for (i = 1; i <= T; ++i) scanf("%d", &j), j %= m, cnt[min(j, m - j)]++;
  for (i = 1; i <= 1000; ++i) mod[i] = i % m;
  cho[1][0] = true;
  ans = dfs(1, 0, 1);
  printf("%d", ans);
  return 0;
}
