Codeforces Round 828 (Div. 3) |
---|
Finished |
An integer array $$$a_1, a_2, \ldots, a_n$$$ is being transformed into an array of lowercase English letters using the following prodecure:
While there is at least one number in the array:
For example, if we initially had an array $$$a = [2, 3, 2, 4, 1]$$$, then we could transform it the following way:
After the transformation all letters are united into a string, in our example we get the string "cacta".
Having the array $$$a$$$ and the string $$$s$$$ determine if the string $$$s$$$ could be got from the array $$$a$$$ after the described transformation?
The first line contains a single integer $$$t$$$ $$$(1 \leq t \leq 10^3$$$) — the number of test cases.
Then the description of the test cases follows.
The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 50$$$) — the length of the array $$$a$$$ and the string $$$s$$$.
The second line of each test case contains exactly $$$n$$$ integers: $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq 50$$$) — the elements of the array $$$a$$$.
The third line of each test case contains a string $$$s$$$ of length $$$n$$$, consisting of lowercase English letters.
For each test case, output "YES", if we can get the string $$$s$$$ from the array $$$a$$$, and "NO" otherwise. You can output each letter in any case.
752 3 2 4 1cacta150a211 22ab41 2 2 1aaab51 2 3 2 1aaaaa61 10 2 9 3 8azzfdb71 2 3 4 1 1 2abababb
YES YES YES NO YES YES NO
The first test case corresponds to the sample described in the statement.
In the second test case we can choose the number $$$50$$$ and the letter a.
In the third test case we can choose the number $$$11$$$ and the letter a, after that $$$a = [a, 22]$$$. Then we choose the number $$$22$$$ and the letter b and get $$$a = [a, b]$$$.
In the fifth test case we can change all numbers one by one to the letter a.
Name |
---|