


1. Both STR and PTR consist of English uppercase letters.
2. Length of string 'STR' will always be greater than or equal to the length of string ‘PTR’.
3. In case, there is no anagram substring, then return an empty sequence.
4. In case of more than one anagrams, return the indices in increasing order.
The first line of input contains an integer 'T' representing the number of test cases or queries to be processed. Then the test case follows.
The first line of each test case contains two space-separated integers ‘N’ and ‘M’ where ‘N’ denotes the number of characters in 'STR', and ‘M’ denotes the number of characters in ‘PTR’.
The second line of each test case contains the string 'STR'.
The third line of each test case contains the string ‘PTR’.
For each test case, print a sequence of all the starting indices of the anagram substrings present in the given string 'STR'.
Print the output of each test case in a separate line.
You do not need to print anything; it has already been taken care of. Just implement the function.
1 <= T <= 100
1 <= N <= 10^5
1 <= M <= N
Time limit: 1 second
We have a brute force solution to this problem. We find all substrings of STR of length M (length of PTR) and store indices of those substrings in ‘ANAGRAM_INDICIES’ which are the anagrams of given string PTR.
Here is the complete algorithm -