For N number of alphabet pairs(in upper or lower case), count the occurrence of the given alphabet pairs in a string S of size M. Output the number of pairs found in the string S, out of total N pairs.
Note: Finding the pair means finding both the characters in a particular pair in the string.
First line of input is an integer T, denoting the number of test cases. For each test case, enter two integers N and M on the same line, denoting the number of pairs of alphabets to be searched for and the size of the string S, respectively. Next line of input comprises of the N alphabet pairs separated by a single space in between. The last line of input comprises of the string S of size M.
The only line of output for each test case is an integer that tells the number of pairs (<=N) that occured in the string S. If no pair is found, the output will be zero.
A G d i P o
F E n O F s
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.