欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1278A.Shuffle Hashing
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:
- take the password , consisting of lowercase Latin letters, and shuffle the letters randomly in it to obtain ( can still be equal to );
- generate two random strings, consisting of lowercase Latin letters, and (any of these strings can be empty);
- the resulting hash , where addition is string concatenation.
For example, let the password "abacaba". Then can be equal to "aabcaab". Random strings "zyx" and "kjh". Then "zyxaabcaabkjh".
Note that no letters could be deleted or added to to obtain , only the order could be changed.
Now Polycarp asks you to help him to implement the password check module. Given the password and the hash , check that can be the hash for the password .
Your program should answer independent test cases.
Input
The first line contains one integer () — the number of test cases.
The first line of each test case contains a non-empty string , consisting of lowercase Latin letters. The length of does not exceed .
The second line of each test case contains a non-empty string , consisting of lowercase Latin letters. The length of does not exceed .
Output
For each test case print the answer to it — "YES" if the given hash could be obtained from the given password or "NO" otherwise.
Note
The first test case is explained in the statement.
In the second test case both and are empty and "threetwoone" is shuffled.
In the third test case the hash could not be obtained from the password.
In the fourth test case "n", is empty and "one" is 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
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |