You are given a string $$$s$$$ consisting of characters A and B.
Your task is to split it into blocks of length $$$1$$$ and $$$2$$$ in such a way that
Strings "AA" and "BB" are prohibited. Each character of the initial string $$$s$$$ should belong to exactly one block.
The first line contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Next, $$$t$$$ independent cases follow.
The first line of each test case contains a single string $$$s$$$ ($$$1 \le |s| \le 5 \cdot 10^5$$$) consisting only of characters A and/or B.
The second line of each test case contains four integers $$$a$$$, $$$b$$$, $$$ab$$$, and $$$ba$$$ ($$$0 \le a, b, ab, ba \le 5 \cdot 10^5$$$) — the maximum allowed number of strings "A", "B", "AB", and "BA" correspondingly.
It's guaranteed that the total length of $$$s$$$ doesn't exceed $$$5 \cdot 10^5$$$ over all test cases.
For each test case, print YES if it's possible to split string $$$s$$$. Otherwise, print NO.
7A0 0 10 10B0 1 0 0ABA0 0 1 1ABBABAAB5 5 0 0ABABBAABBAAB1 1 2 3ABBBBAB0 3 2 0BAABBA1 3 2 0
NO YES NO YES YES YES NO
In the third test case, all possible splits are: A|B|A, AB|A or A|BA. All of them have at least one "A".
In the fourth test case, one of the possible splits is the following: A|B|B|A|B|A|A|B.
In the fifth test case, one of the possible splits is the following: A|BA|B|BA|AB|BA|AB.
Name |
---|