The first line of the input contains a single integer T, indicating there are T cases.
In each case, the first line contains five integers N, the numbers of problems; X, the deadline of problems of collection A; Y, the deadline of problems of collection B; W, the initial coding level of Captain Chen; and Z, which was mentioned above. Next there are N lines, each describing one problem and containing two integers Ci and Di, which are mentioned above. Following the Ci and Di there is a character in each line. The character is either ‘A’ or ‘B’, indicating which collection the problem belongs to.
We guarantee that 0<N<=1000, 0<X, Y<=1000000, 0<Z<=1000, 0<=W<=10^9, 0<=Ci<=10^9, 0<=Di<=1000. Please notice that if the deadline of a problem is X, you can solve the problem in X hours but not X+1 hours.
There are about 1000 cases whose N is no more than 10, about 30 cases whose N is no more than 100, and no more than 5 cases whose N is larger than 100.