monil-aur-abhi-ki-dosti-2

Jai and Veeru are best friends and are very fond of solving different problems. One day Jai decided to challenge Veeru by giving him a programming problem . Jai gives Veeru a pattern (P) and a long string (S) and asks Veeru to find whether there exists any permutation of the pattern (P) in the string (S).

Input: 
First line contains number of test cases T.Each test case contains two lines ,first line contains pattern (P) and next line contains a text string(S).
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(P) exists in the text string(S).

Constraints:
1 ≤ T ≤ 100,
1 ≤ |P| ≤ 1000,
1 ≤ |S| ≤ 100000.

SAMPLE INPUT
3
dust
stud
horrer
rorrhoe
code
decode

SAMPLE OUTPUT
YES
NO
YES

Source: hackerearth | Difficulty: MEDIUM
Tags: String algorithms


Solutions: