#include <bits/stdc++.h>
using namespace std;
const int N = 130, mod = 1e9 + 7;
int n, m, t, op;
int cnt[N], x[N];
bitset<N * 2> s[8];
int get_ans(int sum) {
  int res = 1;
  for (int i = 1; i < sum; i++) res = 1LL * res * cnt[x[i]] % mod;
  return res;
}
int dfs(int sum, int last) {
  int ans = get_ans(sum);
  if (sum > 6) return ans;
  for (int i = last + 1; i <= m / 2; i++) {
    if (!cnt[i]) continue;
    if (s[sum - 1][i] || s[sum - 1][m - i]) continue;
    x[sum] = i;
    if (sum <= 5) {
      s[sum] = s[sum - 1];
      s[sum] |= s[sum - 1] << i;
      s[sum] |= s[sum - 1] >> i;
      s[sum] |= s[sum - 1] << (m - i);
      s[sum] |= s[sum - 1] >> (m - i);
    }
    ans += dfs(sum + 1, i);
    if (ans >= mod) ans -= mod;
  }
  return ans;
}
int main() {
  scanf("%d%d%d", &n, &m, &t);
  for (int i = 1; i <= t; i++) {
    scanf("%d", &op);
    op %= m;
    op = min(op, m - op);
    cnt[op]++;
  }
  s[0][0] = 1;
  printf("%d", dfs(1, 0));
}
