#include <bits/stdc++.h>
using namespace std;
int s[100];
int q[10];
const int mod = 1000000000 + 7;
int n, m;
int flag[7][123];
int mo[400];
inline int get(int a) {
  int ans = 1, i;
  for (i = 0; i < a; ++i) ans = (long long)ans * s[q[i]] % mod;
  return ans;
}
int dfs(int a, int b) {
  int ans = get(a), tmp;
  int i, j;
  if (a < 6) {
    for (i = b + 1; i <= m / 2; ++i)
      if (flag[a][i] == false) {
        q[a] = i;
        if (a < 5) {
          for (j = 0; j < m; ++j) flag[a + 1][j] = false;
          for (j = 0; j < m; ++j)
            if (flag[a][j]) {
              flag[a + 1][j] = flag[a + 1][mo[j + i]] =
                  flag[a + 1][mo[j - i + m]] = true;
            }
        }
        tmp = dfs(a + 1, i);
        ans += tmp;
        if (ans >= mod) ans -= mod;
      }
  }
  return ans;
}
int main() {
  int t, tt;
  scanf("%d %d %d\n", &n, &m, &t);
  int i;
  for (i = 0; i < t; ++i) {
    scanf("%d", &tt);
    s[min(tt % m, m - tt % m)]++;
  }
  for (i = 0; i < m * 2; ++i) mo[i] = i % m;
  flag[0][0] = true;
  int ans = dfs(0, 0);
  printf("%d\n", ans);
  return 0;
}
