Fountains

time limit per test 2 second memory limit per test 256 megabytes
Arkady plays Gardenscapes a lot. Arkady wants to build two new fountains. There are n available fountains, for each fountain its beauty and cost are known. There are two types of money in the game: coins and diamonds, so each fountain cost can be either in coins or diamonds. No money changes between the types are allowed.

Help Arkady to find two fountains with maximum total beauty so that he can buy both at the same time.

## Input

The first line contains three integers n, c and d (2≤n≤100000, 0≤c,d≤100000) — the number of fountains, the number of coins and diamonds Arkady has.
The next n lines describe fountains. Each of these lines contain two integers bi and pi (1≤bi,pi≤100000) — the beauty and the cost of the i-th fountain, and then a letter “C” or “D”, describing in which type of money is the cost of fountain i: in coins or in diamonds, respectively.

## Output

Print the maximum total beauty of exactly two fountains Arkady can build. If he can’t build two fountains, print 0.