Stage One Confusion


Parsa is taking a multiple-choice exam with nn questions. He looks at the questions in order, answers some of them, and never goes back.

Parsa's answer sheet contains mm answers. The ii-th answer says that he chose option cic_i for question pip_i. The question numbers on the sheet are strictly increasing.

Parsa may have made at most one copying mistake on the sheet. Such a mistake could have happened to one consecutive block of his answers: while copying that block onto the sheet, every intended question number in the block was changed by the same nonzero offset. More precisely, starting from Parsa's intended answer sheet, one copying mistake consists of choosing one block ~l, l+1, \ldots, randonenonzerointeger and one nonzero integer d,thenchangingeveryquestionnumberinthatblockfrom, then changing every question number in that block from q_i~ to qi+dq_i+d.

Both the intended question numbers and the written question numbers must be strictly increasing and between 11 and nn. You may also decide that no mistake was made.

Given the correct answer key and Parsa's answer sheet as written, find the largest possible number of answers Parsa could have gotten correct before the copying mistake was made.

In the picture, one block is shifted by d=1d=1 while being copied onto the sheet.

Input

The first line contains an integer TT, the number of test cases.

Each test case has the following format:

  • The first line contains two integers nn and mm.
  • The second line contains a string SS of length nn. The ii-th character is the correct answer for question ii.
  • The next mm lines each contain an integer pip_i and a character cic_i, meaning Parsa wrote answer cic_i for question pip_i.

If m>0m > 0, it is guaranteed that 1p1<p2<<pmn1 \le p_1 < p_2 < \cdots < p_m \le n.

Output

For each test case, print one integer: the maximum possible number of correct answers on Parsa's intended answer sheet, before any copying mistake.

Constraints

  • 1T1041 \le T \le 10^4
  • 1n20001 \le n \le 2000
  • 0mn0 \le m \le n
  • The sum of nn over all test cases is 2000\le 2000.
  • Each character of SS and each cic_i is one of A, B, C, D, or E.

Example 1

Input 1
5
5 4
AECDB
1 A
2 A
4 C
5 B
7 2
AAACDAA
1 C
3 D
7 2
AAACDAA
1 C
2 D
10 5
ABECCDBAEA
3 B
4 E
6 C
8 A
10 E
4 0
ABCD
Output 1
3
1
2
4
0
Explanation

In the first test case, the score on the sheet as written is 22. Parsa could have originally written that answer for question 33, then copied it as question 44 by mistake. Before that mistake, his score would have been 33.

Comments0


No comments yet

Be the first to comment.

New comment


Log in to join the discussion.