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, t, d = map(int, input().split())\ncoin = [[(0, 0), (0, 0)] for i in range(100001)]\ndiam = [[(0, 0), (0, 0)] for i in range(100001)]\nf = []\nfor i in range(n):\n    b, c, q = input().split()\n    b = int(b)\n    c = int(c)\n    if q == 'C':\n        f.append((b, c, 1))\n        if coin[c][0][0] < b:\n            coin[c][1] = coin[c][0]\n            coin[c][0] = (b, i)\n        elif coin[c][1][0] < b:\n            coin[c][1] = (b, i)\n    else:\n        f.append((b, c, 2))\n        if diam[c][0][0] < b:\n            diam[c][1] = diam[c][0]\n            diam[c][0] = (b, i)\n        elif diam[c][1][0] < b:\n            diam[c][1] = (b, i)\nfor i in range(2, 100001):\n    if coin[i][0][0] < coin[i - 1][0][0]:\n        coin[i][1] = max(coin[i][0], coin[i - 1][1])\n        coin[i][0] = coin[i - 1][0]\n    else:\n        coin[i][1] = max(coin[i - 1][1], coin[i][1])\n    if diam[i][0][0] < diam[i - 1][0][0]:\n        diam[i][1] = max(diam[i][0], diam[i - 1][1])\n        diam[i][0] = diam[i - 1][0]\n    else:\n        diam[i][1] = max(diam[i - 1][1], diam[i][1])\np = False\nans = 0\nfor i in range(n):\n    fnt = f[i]\n    #print(fnt)\n    if fnt[2] == 1:\n        if t >= fnt[1]:\n            s = t - fnt[1]\n            if coin[s][0][0] > 0 and coin[s][0][1] != i:\n                ans = max(fnt[0] + coin[s][0][0], ans)\n                p = True\n            elif coin[s][1][0] > 0:\n                ans = max(fnt[0] + coin[s][1][0], ans)\n                p = True\n            if diam[d][0][0] > 0:\n                ans = max(fnt[0] + diam[d][0][0], ans)\n                p = True\n    else:\n        if d >= fnt[1]:\n            s = d - fnt[1]\n            if diam[s][0][0] > 0 and diam[s][0][1] != i:\n                ans = max(fnt[0] + diam[s][0][0], ans)\n                p = True\n            elif diam[s][1][0] > 0:\n                ans = max(fnt[0] + diam[s][1][0], ans)\n                p = True\n            if coin[t][0][0] > 0:\n                ans = max(fnt[0] + coin[t][0][0], ans)\n                p = True\nif p:\n    print(ans)\nelse:\n    print(0)"
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 16010276