A ternary string is a sequence of digits, where each digit is either 0, 1, or 2.
For a ternary string, Chiaki can perform any of the following operations:
Chiaki has a ternary string s of length n and m other ternary strings t_1,t_2,…,t_m. For each ternary string t_i, she would like to know the number of pairs (l,r) (1≤l≤r≤n) such that the substring s_l..r can become t_i after performing several above operations.
There are multiple test cases. The first line of input contains an integer T, indicating the number of test cases. For each test case:
The first line contains two integers n and m (1≤n,m≤106) -- the length of s and the number of other ternary strings.
The second line contains a ternary string s of length n.
Each of the next m lines contains a ternary string t_i (1≤∣t_i∣≤106).
It is guaranteed that the sum of the length of all strings over all test cases does not exceed 2×106.
For each test cases, output m lines, where the i-th line contains an integer denoting the answer for ternary string t_i.