On the first line a positive integer: the number of test cases, at most 100. After that per test case:
One line with an integer : the number of regions.
One line with integers : the number of your armies on each region. A number 0 indicates that a region is controlled by your opponents, while a positive number indicates that it is under your control.
lines with characters, where each character is either Y or N. The -th character of the -th line is Y if regions and border, and N otherwise. This relationship is symmetric and the -th character of the -th line will always be N.
In every test case, you control at least one region, and your opponents control at least one region. Furthermore, at least one of your regions borders at least one of your opponents' regions.
输出格式
Per test case:
One line with an integer: the maximum number of armies on your weakest border region after one turn of moving.