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 ≤ 100 000, 0 ≤ c, d ≤ 100 000) — 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 b_{i} and p_{i} (1 ≤ b_{i}, p_{i} ≤ 100 000) — 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.


-----Examples-----
Input
3 7 6
10 8 C
4 3 C
5 6 D

Output
9

Input
2 4 5
2 5 C
2 1 D

Output
0

Input
3 10 10
5 5 C
5 5 C
10 11 D

Output
10



-----Note-----

In the first example Arkady should build the second fountain with beauty 4, which costs 3 coins. The first fountain he can't build because he don't have enough coins. Also Arkady should build the third fountain with beauty 5 which costs 6 diamonds. Thus the total beauty of built fountains is 9.

In the second example there are two fountains, but Arkady can't build both of them, because he needs 5 coins for the first fountain, and Arkady has only 4 coins.

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = "n, c, d = list(map(int, input().split()))\ncoin = []\ndiamond = []\nfor i in range(n):\n    tmp = input().split()\n    if tmp[-1] == 'C' and int(tmp[1]) <= c:\n        coin.append(list(map(int, tmp[:2])))\n    if tmp[-1] == 'D' and int(tmp[1]) <= d:\n        diamond.append(list(map(int, tmp[:2])))\nres1 = 0\nmc = -float('inf')\nfor i in coin:\n    if mc < i[0] and i[1] <= c:\n        mc = i[0]\nmd = -float('inf')\nfor i in diamond:\n    if md < i[0] and i[1] <= d:\n        md = i[0]\nif mc != -float('inf') and md != -float('inf'):\n    res1 = md + mc\ncoin.sort(key=lambda x: x[1], reverse=True)\ndiamond.sort(key=lambda x: x[1], reverse=True)\nprefc = [0 for i in range(len(coin))]\nprefd = [0 for i in range(len(diamond))]\nif len(coin):\n    prefc[-1] = coin[-1][0]\nif len(diamond):\n    prefd[-1] = diamond[-1][0]\nfor i in range(len(coin) - 2, -1, -1):\n    prefc[i] = max(prefc[i + 1], coin[i][0])\nfor i in range(len(diamond) - 2, -1, -1):\n    prefd[i] = max(prefd[i + 1], diamond[i][0])\nres2 = 0\nres3 = res2\nfor i in range(len(coin)):\n    p = c - coin[i][1]\n    l = i\n    r = len(coin) - 1\n    while r - l > 1:\n        m = (r + l) // 2\n        if coin[m][1] > p:\n            l = m\n        else:\n            r = m\n    if coin[r][1] <= p and r > i:\n        res2 = max(res2, coin[i][0] + prefc[r])\nfor i in range(len(diamond)):\n    p = d - diamond[i][1]\n    l = i\n    r = len(diamond) - 1\n    while r - l > 1:\n        m = (r + l) // 2\n        if diamond[m][1] > p:\n            l = m\n        else:\n            r = m\n    if diamond[r][1] <= p and r > i:\n        res3 = max(res3, diamond[i][0] + prefd[r])\nprint(max(res1, res2, res3))\n"
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 14839