#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
using namespace std;
const int mod = 1000000007;
int n, m, t, a[8];
long long cnt[125];
bool vis[8][125];
int get_mod[1000];
inline void add(int &x, int y) { (x += y) >= mod && (x -= mod); }
inline int mul(int x, int y) { return 1LL * x * y - 1LL * x * y / mod * mod; }
inline int destroy(int x) {
  int ans = 1;
  for (int i = 0; i < x; ++i) ans = mul(ans, cnt[a[i]]);
  return ans;
}
int dfs(int x, int pre) {
  int res = destroy(x);
  if (x < 6)
    for (int i = pre + 1; i <= m / 2; ++i)
      if (!vis[x][i]) {
        a[x] = i;
        if (x < 5) {
          for (int j = 0; j < m; ++j) vis[x + 1][j] = false;
          for (int j = 0; j < m; ++j)
            if (vis[x][j]) {
              vis[x + 1][j] = true;
              vis[x + 1][get_mod[j - i + m]] = true;
              vis[x + 1][get_mod[i + j]] = true;
            }
        }
        add(res, dfs(x + 1, i));
      }
  return res;
}
int main() {
  scanf("%d %d %d", &n, &m, &t);
  for (int i = 1; i <= t; ++i) {
    int x;
    scanf("%d", &x);
    if ((x %= m) != 0) cnt[min(x, m - x)]++;
  }
  for (int i = 0; i < 1000; ++i) get_mod[i] = i % m;
  vis[0][0] = true;
  printf("%d\n", dfs(0, 0));
  return 0;
}
