#include <bits/stdc++.h>
using namespace std;
int n, m, t;
int cnt[120];
int a[10];
long long total = 1;
int m2;
unsigned long long allMask;
unsigned long long cache[1 << 16];
inline unsigned long long reverse(unsigned long long x) {
  return cache[x >> 48] + (cache[(x >> 32) & 0xFFFF] << 16) +
         (cache[(x >> 16) & 0xFFFF] << 32) + (cache[x & 0xFFFF] << 48);
}
void solve(int num, unsigned long long used) {
  if (num == 0) {
    for (int i = 1; i < m2; i++) {
      if (cnt[i] > 0) {
        a[0] = i;
        solve(1, 1LL << i);
      }
    }
  } else {
    long long add = 1;
    for (int i = 0; i < num; i++) add = (add * cnt[a[i]]) % 1000000007;
    total = (total + add) % 1000000007;
    for (int i = a[num - 1] + 1; i < m2; i++) {
      if (cnt[i] > 0 && (used & (1LL << i)) == 0) {
        unsigned long long nextUsed =
            used | (1LL << i) | ((used << i) & allMask) |
            (reverse(used >> (m2 - i)) >> (64 - m2 + 1 - (m & 1))) |
            (used >> i) | (reverse(used & ((1LL << i) - 1)) >> (63 - i));
        a[num] = i;
        solve(num + 1, nextUsed);
      }
    }
  }
}
int main() {
  cin >> n >> m >> t;
  for (int i = 0; i < t; i++) {
    int x;
    cin >> x;
    x %= m;
    if (x != 0) cnt[min(x, m - x)]++;
  }
  m2 = m / 2 + 1;
  allMask = (1LL << m2) - 1;
  for (int i = 0; i < (1 << 16); i++) {
    int r = 0;
    for (int j = 0; j < 16; j++)
      if (i & (1 << j)) r |= 1 << (15 - j);
    cache[i] = r;
  }
  solve(0, 0);
  cout << total << endl;
}
