##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
| # | Title | Points | Solved | Admin | |
|---|---|---|---|---|---|
Nasser gives you an array consisting of integers and a string consisting of only the characters 'a' and 'b', both having the same length .
He asks you to count the number of subarrays such that:
The number of ones in the bitwise OR of the elements is equal to the number of 'a' characters in the substring .
A subarray means a continuous segment of the array. For example, in , the subarrays are , , , , , and .
The bitwise OR of several integers is an operation that compares their binary representations bit by bit, and sets each bit to if any of the numbers has that bit equal to .
For example: (binary), (binary), and .
Each test contains multiple test cases. The first line contains a single integer - the number of test cases. The description of the test cases follows.
The first line of each test case contains a single integer - the length of the array and string.
The second line of each test case contains integers - the elements of the array.
The third line of each test case contains a string of length , consisting of characters 'a' and 'b' only.
It is guaranteed that the sum of over all test cases does not exceed .
For each test case, print a single integer — the number of subarrays that satisfy the condition.
, , "aba":
Subarray : (ones = ). The 'a' count in "a" is . Since , this is Valid.
Subarray : (ones = ). The 'a' count in "b" is . Since , this is Invalid.
Subarray : (ones = ). The 'a' count in "a" is . Since , this is Invalid.
Subarray : (ones = ). The 'a' count in "ab" is . Since , this is Invalid.
Subarray : (ones = ). The 'a' count in "ba" is . Since , this is Invalid.
Subarray : (ones = ). The 'a' count in "aba" is . Since , this is Valid.
Result: The valid subarrays are and . Answer: