#include <bits/stdc++.h>
using namespace std;
const int maxn = 123, mod = 1e9 + 7;
int num[maxn], a[maxn], n, m, t;
bitset<maxn> s[8];
int temp;
long long dfs(int cnt, int minn) {
  long long ans = 1;
  for (int i = 0; i < cnt; i++) ans *= num[a[i]], ans %= mod;
  if (cnt < 6) {
    for (int i = minn; i <= m / 2; i++) {
      if (!num[i] || s[cnt][i] || s[cnt][m - i]) continue;
      a[cnt] = i;
      s[cnt + 1] = s[cnt];
      s[cnt + 1] |= s[cnt] << i;
      s[cnt + 1] |= s[cnt] >> i;
      s[cnt + 1] |= s[cnt] << (m - i);
      s[cnt + 1] |= s[cnt] >> (m - i);
      ans += dfs(cnt + 1, i + 1);
      ans %= mod;
    }
  }
  return ans;
}
int main() {
  scanf("%d%d%d", &n, &m, &t);
  for (int i = 1; i <= t; i++) {
    scanf("%d", &temp);
    temp %= m;
    temp = min(temp, m - temp);
    num[temp]++;
  }
  s[0][0] = 1;
  printf("%lld\n", dfs(0, 1));
}
