The first line contains the number of strings in the dictionary N and the number of questions M, separated by a space. (1≤N,M≤2×106)
Each of the next N lines contains one string of the dictionary.
Each of the following M lines contains the two strings P and Q of one question, separated by a space.
Every dictionary string and every P and Q consists only of the letters 'A', 'G', 'C', and 'U', and each string has length at most 105. The total length of the dictionary strings, the total length of the P strings, and the total length of the Q strings are each at most 2×106.