


1. There may be more than one occurrence of 'P' in 'S'.
2. Some alphabets in the strings may be repeated.
The first line of input contains a single integer 'T', representing the number of test cases
Then the 'T' test cases follow.
The first line of each test case contains two space-separated strings 'P' and 'S' respectively.
For each test case, print a single line containing “YES” if string 'P' is present in string 'S' as a substring, otherwise print “NO”.
The output for each test case will be printed in a separate line.
You don’t have to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 100
1 <= |S| <= 10000
1 <= |P| < |S|
Where |S| and |P| represents the length of the string 'S' and 'P' respectively.
Time limit: 1 sec.
The idea is to generate all the substrings of ‘S’ of size equal to the size of ‘P’ and match each of them with the ‘P’.
The basic idea of KMP is to generate and use LPS array here LPS means longest proper prefix which is also a suffix. For example, if a string is ‘aada’ then :-
Proper prefixes are :[a, aa, aad]
Proper suffix are :[a,da,ada].
The LPS array helps us to skip characters while matching.
Basically this algorithm works in two parts where the first part is to generate the LPS array and the second part is to use this array to skip characters while matching P with S.