#include <bits/stdc++.h>
using namespace std;
int Get() {
  char c;
  while (c = getchar(), c < '0' || c > '9')
    ;
  int X = 0;
  while (c >= '0' && c <= '9') {
    X = X * 10 + c - 48;
    c = getchar();
  }
  return X;
}
const int Mod = 1000000007;
int N, Ans;
int Count[61];
long long F(long long A, int P) { return A & ((1LL << P) - 1); }
long long Low(long long A, long long B, int P) {
  if (N <= 60) return (F(A, N - P) << P) | (A >> (N - P));
  if (P <= 60 && N - 60 >= P) return (F(A, 60 - P) << P) | (B >> (N - 60 - P));
  if (P <= 60 && N - 60 < P)
    return (F(A, 60 - P) << P) | (B << (P - N + 60)) | (A >> (N - P));
  return (A >> (N - P)) | (F(B, N - P) << (P - N + 60));
}
long long High(long long A, long long B, int P) {
  if (N <= 60) return 0;
  if (P <= 60 && N - 60 >= P) return (A >> (60 - P)) | (F(B, N - 60 - P) << P);
  if (P <= 60 && N - 60 < P) return F(A >> (60 - P), N - 60);
  return (B >> (N - P)) | (F(A, N - P) << (P - 60));
}
void DFS(int P, long long Current, long long A, long long B) {
  if (P * 2 > N) {
    Ans = (Ans + Current) % Mod;
    return;
  }
  DFS(P + 1, Current, A, B);
  if (!Count[P]) return;
  long long _A = Low(A, B, P), _B = High(A, B, P);
  if ((A & _A) | (B & _B)) return;
  DFS(P + 1, Current * Count[P] % Mod, A | _A, B | _B);
}
int main() {
  Get();
  N = Get();
  memset(Count, 0, sizeof(Count));
  for (int M = Get(); M--;) {
    int X = Get() % N;
    if (X * 2 > N) X = N - X;
    Count[X]++;
  }
  Ans = 0;
  DFS(0, 1, 1, 0);
  printf("%d\n", Ans);
  return 0;
}
