| SCPC Teens 2025 |
|---|
| Закончено |
You are given an array $$$a$$$ of $$$n$$$ integers, and a binary string $$$b$$$ of length $$$n$$$.
For each $$$i$$$ from $$$1$$$ to $$$n$$$ (in order), you will perform one of the following actions:
The first line of the input contains a single integer $$$tc$$$ $$$(1 \le tc \le 10^5)$$$ — the number of testcases.
The first line of each test case contains a single integer $$$n$$$ $$$(1 \le n \le 5 \cdot 10^5)$$$ — the length of the array.
The second line of each test case contains $$$n$$$ integers $$$a_i$$$ $$$(1 \le a_i \le n)$$$ — the array $$$a$$$.
The third line of each test case contains a binary string $$$b$$$ of length $$$n$$$.
It is guaranteed that the sum of $$$n$$$ over all testcases doesn't exceed $$$5 \cdot 10^5$$$.
For each test case, print the final array after performing all the operations.
231 2 311154 5 1 1 201101
3 1 2 2 1 5 4 1
| Название |
|---|


