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() if ci=="A":g[i%(X+Y)][1]+=int(p) else:g[i%(X+Y)][2]+=int(p) 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