#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
int n, m, t;
vector<int> tanks;
void read() {
  cin >> n >> m >> t;
  tanks.resize(m);
  for (int i = 0; i < t; ++i) {
    int tank;
    cin >> tank;
    tank = tank % m;
    if (tank > m / 2) tank = m - tank;
    ++tanks[tank];
  }
}
long long ans = 0;
void f(bitset<130> used, int pos, int numUsed, long long prod, int all) {
  ans = (ans + prod) % mod;
  if (numUsed > 6) return;
  for (int i = pos + 1; i <= m / 2; ++i) {
    if (!used[i] && tanks[i]) {
      bitset<130> u = used | (used << i) | (used >> i) | (used << (m - i)) |
                      (used >> (m - i));
      f(u, i, numUsed + 1, (prod * tanks[i]) % mod, 10 * all + i);
    }
  }
}
int main() {
  read();
  bitset<130> u;
  u[0] = 1;
  f(u, 0, 0, 1, 0);
  cout << ans << endl;
  return 0;
}
