It Is Cold

No attempts yetTime limit1sMemory limit128 MB

Problem

Dr. Ziad Najem is called the godfather of the ACPC. The regional contest was held in Alexandria, Egypt, and the weather was very cold. Inside the contest hall the fans were running anyway. Dr. Ziad wants to know how fast the air arrives at each team.

A team has NN fans standing in a straight line to its right. Fan ii blows with speed SiS_i in direction CiC_i. T means the fan blows toward the team, A means it blows away from the team. Fan 0 is the closest to the team and fan N1N-1 is the farthest.

The air starts at the farthest fan and travels along the line, passing one fan at a time. Two flows in the same direction add their speeds.

Fan 1Fan 2Result
DirectionTTT
Speed242 + 4 = 6

Two flows facing each other cancel, and the stronger direction survives.

Fan 1Fan 2Result
DirectionATT
Speed244 - 2 = 2

Air that ends up moving away from the team leaves the line and never comes back, so the fans closer to the team start again from speed 0.

Input

The first line contains the number of teams TT. Each team takes three lines. The first line has the number of fans NN. The second line has NN integers SiS_i separated by spaces, the speed of the air produced by fan ii (0i<N0 \le i < N). The third line has NN characters CiC_i separated by spaces, the direction of each fan.

  • T100T \le 100
  • 0<N10000 < N \le 1000
  • 0Si10000000000 \le S_i \le 1000000000

Output

Print TT lines, one per team. Each line holds a single integer SS, the speed of the air that reaches the team. Print 0 when no air reaches the team.