eolymp
bolt
Try our new interface for solving problems
Məsələlər

Encrypted Password

Encrypted Password

Encrypting passwords is one of the most important problems nowadays, and you trust only the encryption algorithms which you invented, and you have just made a new encryption algorithm. Given a password which consists of only lower case English letters, your algorithm encrypts this password using the following \textbf{3} steps (in this given order): \begin{enumerate} \item Swap two dierent characters of the given password (you can do this step zero or more times). \item Append zero or more lower case English letters at the beginning of the output of step one. \item Append zero or more lower case English letters to the end of the output of step two. \end{enumerate} And the encrypted password is the output of step three. You have just nished implementing the above algorithm and applied it on many passwords. Now you want to make sure that there are no bugs in your implementation, so you decided to write another program which validates the output of the encryption program. Given the encrypted password and the original password, your job is to check whether the encrypted password may be the result of applying your algorithm on the original password or not. \InputFile Your program will be tested on one or more test cases. The first line of the input will be a single integer \textbf{T}, the number of test cases (\textbf{1} ≤ \textbf{T} ≤ \textbf{100}). Followed by the test cases, each test case is on two lines. The first line of each test case contains the encrypted password. The second line of each test case contains the original password. Both the encrypted password and the original password are at least \textbf{1} and at most \textbf{100000} lower case English letters (from '\textbf{a}' to '\textbf{z}'), and the length of the original password is less than or equal the length of the encrypted password. \OutputFile For each test case, print on a single line one word, "\textbf{YES}" (without the quotes) if applying the algorithm on the original password may generate the encrypted password, otherwise print "\textbf{NO}" (without the quotes).
Zaman məhdudiyyəti 1 saniyə
Yaddaşı istafadə məhdudiyyəti 64 MiB
Giriş verilənləri #1
3
abcdef
ecd
cde
ecd
abcdef
fcd
Çıxış verilənləri #1
YES
YES
NO
Mənbə Arab Collegiate Programming Contest 2012