CF1278A.Shuffle Hashing

传统题 时间 2000 ms 内存 256 MiB 5 尝试 1 已通过 1 标签

Shuffle Hashing

Polycarp has built his own web service. Being a modern web service it includes login feature. And that always implies password security problems.

Polycarp decided to store the hash of the password, generated by the following algorithm:

  1. take the password pp, consisting of lowercase Latin letters, and shuffle the letters randomly in it to obtain pp' (pp' can still be equal to pp);
  2. generate two random strings, consisting of lowercase Latin letters, s1s_1 and s2s_2 (any of these strings can be empty);
  3. the resulting hash h=s1+p+s2h = s_1 + p' + s_2, where addition is string concatenation.

For example, let the password p=p = "abacaba". Then pp' can be equal to "aabcaab". Random strings s1=s1 = "zyx" and s2=s2 = "kjh". Then h=h = "zyxaabcaabkjh".

Note that no letters could be deleted or added to pp to obtain pp', only the order could be changed.

Now Polycarp asks you to help him to implement the password check module. Given the password pp and the hash hh, check that hh can be the hash for the password pp.

Your program should answer tt independent test cases.

Input

The first line contains one integer tt (1t1001 \le t \le 100) — the number of test cases.

The first line of each test case contains a non-empty string pp, consisting of lowercase Latin letters. The length of pp does not exceed 100100.

The second line of each test case contains a non-empty string hh, consisting of lowercase Latin letters. The length of hh does not exceed 100100.

Output

For each test case print the answer to it — "YES" if the given hash hh could be obtained from the given password pp or "NO" otherwise.

Note

The first test case is explained in the statement.

In the second test case both s1s_1 and s2s_2 are empty and p=p'= "threetwoone" is pp shuffled.

In the third test case the hash could not be obtained from the password.

In the fourth test case s1=s_1= "n", s2s_2 is empty and p=p'= "one" is pp shuffled (even thought it stayed the same).

In the fifth test case the hash could not be obtained from the password.

Samples

5
abacaba
zyxaabcaabkjh
onetwothree
threetwoone
one
zzonneyy
one
none
twenty
ten
YES
YES
NO
YES
NO

在线编程 IDE

建议全屏模式获得最佳体验