Vasya has a set of 4n strings of equal length, consisting of lowercase English letters "a", "b", "c", "d" and "e". Moreover, the set is split into n groups of 4 equal strings each. Vasya also has one special string a of the same length, consisting of letters "a" only.

Vasya wants to obtain from string a some fixed string b, in order to do this, he can use the strings from his set in any order. When he uses some string x, each of the letters in string a replaces with the next letter in alphabet as many times as the alphabet position, counting from zero, of the corresponding letter in string x. Within this process the next letter in alphabet after "e" is "a".

For example, if some letter in a equals "b", and the letter on the same position in x equals "c", then the letter in a becomes equal "d", because "c" is the second alphabet letter, counting from zero. If some letter in a equals "e", and on the same position in x is "d", then the letter in a becomes "c". For example, if the string a equals "abcde", and string x equals "baddc", then a becomes "bbabb".

A used string disappears, but Vasya can use equal strings several times.

Vasya wants to know for q given strings b, how many ways there are to obtain from the string a string b using the given set of 4n strings? Two ways are different if the number of strings used from some group of 4 strings is different. Help Vasya compute the answers for these questions modulo 109 + 7.

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 500) — the number of groups of four strings in the set, and the length of all strings.

Each of the next n lines contains a string s of length m, consisting of lowercase English letters "a", "b", "c", "d" and "e". This means that there is a group of four strings equal to s.

The next line contains single integer q (1 ≤ q ≤ 300) — the number of strings b Vasya is interested in.

Each of the next q strings contains a string b of length m, consisting of lowercase English letters "a", "b", "c", "d" and "e" — a string Vasya is interested in.

Output

For each string Vasya is interested in print the number of ways to obtain it from string a, modulo 109 + 7.

Examples

Input

1 1
b
2
a
e


Output

1
1


Input

2 4
aaaa
bbbb
1
cccc


Output

5

Note

In the first example, we have 4 strings "b". Then we have the only way for each string b: select 0 strings "b" to get "a" and select 4 strings "b" to get "e", respectively. So, we have 1 way for each request.

In the second example, note that the choice of the string "aaaa" does not change anything, that is we can choose any amount of it (from 0 to 4, it's 5 different ways) and we have to select the line "bbbb" 2 times, since other variants do not fit. We get that we have 5 ways for the request.
#include <bits/stdc++.h>
using namespace std;
void read_file(bool outToFile = true) {}
const int MAXN = 500 + 99;
int n, m, nq;
char str[MAXN];
int A[MAXN][MAXN], B[MAXN];
int mod_inv[] = {0, 1, 3, 2, 4};
int num;
void swapp(int i, int j) {
  for (int k = 0; k < m; k++) swap(A[i][k], A[j][k]);
}
inline void fix(int &x) {
  x %= 5;
  if (x < 0) x += 5;
}
void debug() {
  printf("...\n");
  for (int i = 0; i < n; i++) {
    for (int j = m - 1; j >= 0; j--) printf("%d%c", A[i][j], " \n"[j == 0]);
  }
  printf("...\n");
}
void gauss() {
  int cur = 0;
  for (int i = m - 1; i >= 0; i--) {
    bool fnd = false;
    for (int j = cur; j < n; j++) {
      if (A[j][i] != 0) {
        swapp(j, cur);
        fnd = true;
        break;
      }
    }
    if (!fnd) {
      continue;
    }
    int x = A[cur][i];
    for (int j = cur + 1; j < n; j++) {
      int y = A[j][i];
      int a = y * mod_inv[x] % 5;
      for (int k = 0; k < m; k++) {
        A[j][k] = A[j][k] - a * A[cur][k];
        fix(A[j][k]);
      }
    }
    cur++;
  }
  int itr = n - cur;
  num = 1;
  for (int i = 0; i < itr; i++) num = num * 5LL % (1000000007);
}
bool can() {
  int cur = 0;
  for (int i = m - 1; i >= 0; i--) {
    if (B[i] == 0) {
      if (A[cur][i] != 0) cur++;
      continue;
    }
    while (cur < n && A[cur][i] == 0) cur++;
    if (cur == n) return false;
    int x = A[cur][i];
    int y = B[i];
    int a = y * mod_inv[x] % 5;
    for (int k = 0; k < m; k++) {
      B[k] = B[k] - a * A[cur][k];
      fix(B[k]);
    }
    cur++;
  }
  return true;
}
int main() {
  read_file();
  while (scanf("%d%d", &n, &m) != -1) {
    for (int i = 0; i < n; i++) {
      scanf("%s", str);
      for (int j = 0; j < m; j++) A[i][j] = str[j] - 'a';
    }
    gauss();
    scanf("%d", &nq);
    while (nq--) {
      scanf("%s", str);
      for (int j = 0; j < m; j++) B[j] = str[j] - 'a';
      int ans = can() ? num : 0;
      printf("%d\n", ans);
    }
  }
}
