cin >> n >> m; int t = 0; for (int i = 1; i <= n; ++i) cin >> a[i], t ^= a[i]; sort(a + 1, a + n + 1); for (int i = 1; i <= n; ++i) for (int o = 0; o < 20; ++o) if (a[i] >> o & 1) h[i] = 1 << o + 1; f[0][0][0] = 1; for (int i = 1, s = 0, t = 1; i <= n; ++i, swap(s, t)) for (int j = 0; j < m; ++j) for (int k = 0; k < h[i]; ++k) f[t][j][k] = add(f[s][j == 0 ? m - 1 : j - 1][k ^ a[i]], f[s][j][k]); if (n % m == 0) f[n & 1][0][t] = add(f[n & 1][0][t], p - 1); cout << f[n & 1][0][t] << "\n"; return0; }