#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 10;
const long long MOD = 1000 * 1000 * 1000 + 7;
int tot[maxn], now[maxn], can[maxn][maxn], mod, mm[maxn * maxn];
inline int Solve(int pos) {
  long long ret = 1;
  for (int i = 1; i <= pos; ++i) ret = ret * tot[now[i]] % MOD;
  return ret;
}
inline int Dfs(int pos, int last) {
  int ret = Solve(pos - 1);
  if (pos <= 6) {
    for (int i = last; i <= mod / 2; ++i) {
      if (can[pos - 1][i] == 0 && tot[i] > 0) {
        now[pos] = i;
        if (pos <= 5) {
          for (int j = 0; j < mod; ++j) can[pos][j] = 0;
          for (int j = 0; j < mod; ++j)
            if (can[pos - 1][j] == 1)
              can[pos][j] = can[pos][mm[(j + i)]] =
                  can[pos][mm[(j - i + mod)]] = can[pos][mm[(i - j + mod)]] = 1;
        }
        ret += Dfs(pos + 1, i + 1);
        if (ret >= MOD) ret -= MOD;
      }
    }
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, m, t;
  cin >> n >> m >> t;
  mod = m;
  for (int i = 1; i <= t; ++i) {
    int f;
    cin >> f;
    f %= m;
    if (f != 0) tot[min(f, m - f)]++;
  }
  for (int i = 0; i <= 100000; ++i) mm[i] = i % m;
  can[0][0] = 1;
  cout << Dfs(1, 1) << endl;
  return 0;
}
