P13116 [HackerEarth] a needle in the haystack 1
普及
题目描述

Our hacker, Little Stuart lately has been fascinated by ancient puzzles. One day going through some really old books he finds something scribbled on the corner of a page. Now Little Stuart believes that the scribbled text is more mysterious than it originally looks, so he decides to find every occurrence of all the permutations of the scribbled text in the entire book. Since this is a huge task, Little Stuart needs your help, he needs you to only figure out if any permutation of the scribbled text exists in the given text string, so he can save time and analyze only those text strings where a valid permutation is present.

Input:
First line contains number of test cases T.Each test case contains two lines ,first line contains pattern and next line contains a text string. All characters in both the strings are in lowercase only [a-z].

Output:
For each test case print "YES" or "NO" (quotes for clarity) depending on whether any permutation of the pattern exists in the text string.

Constraints:
1 ≤ T ≤ 100
1 ≤ |Pattern| ≤ 1000
1 ≤ |Text String| ≤ 100000

SAMPLE INPUT
3
hack
indiahacks
code
eddy
coder
iamredoc

SAMPLE OUTPUT
YES
NO
YES

输入格式

见题面

输出格式

见题面

样例输入
3 hack indiahacks code eddy coder iamredoc SAMPLE
样例输出
YES NO YES