@staticmethod
def b():
    (n, a, b) = map(int, sys.stdin.readline().split())
    res = defaultdict(int)
    for _ in range(n):
        (s, d) = sys.stdin.readline().split()
        d = int(d)
        res[s] += min(max(d, a), b)
    res = (res['East'] - res['West'])
    if (res == 0):
        ans = 0
    elif (res > 0):
        ans = f'East {res}'
    else:
        ans = f'West {(- res)}'
    print(ans)
@staticmethod
def b():
    (n, a, b) = map(int, sys.stdin.readline().split())
    res = defaultdict(int)
    for _ in range(n):
        (s, d) = sys.stdin.readline().split()
        d = int(d)
        res[s] += min(max(d, a), b)
    res = (res['East'] - res['West'])
    if (res == 0):
        ans = 0
    elif (res > 0):
        ans = f'East {res}'
    else:
        ans = f'West {(- res)}'
    print(ans)