N,X,Y=map(int,input().split()) g=[[0 for _ in range(3)] for _ in range(X+Y)] for i in range(N): p,ci=input().split() a=0 b=0 if ci=="A":a=int(p) else:b=int(p) g[i%(X+Y)][1]+=a g[i%(X+Y)][2]+=b g[i%(X+Y)][0]=g[i%(X+Y)][2]-g[i%(X+Y)][1] g.sort() ans=0 for i in range(X+Y): if i