from collections import deque class MoAlgorithm(): BIT=24 MASK=(1<>self.BIT,self.query[i]&self.MASK bac=lf//backet aft[i]=(((bac<<20)+(ri*(-1 if bac&1 else 1)))<>self.BIT,self.query[i]&self.MASK while rir: ri-=1;delete_r(ri) while lfl: lf-=1;add_l(lf) ans[i]=fix() return ans def add_l(p): global wa,sol,solved,pena if res[p][1]=="WA": if len(wa[res[p][0]])==0: wa[res[p][0]].appendleft(1) elif wa[res[p][0]][0]==0: wa[res[p][0]].appendleft(1) pena+=1 else: wa[res[p][0]][0]+=1 if solved[res[p][0]]!=0: pena+=1 else: wa[res[p][0]].appendleft(0) solved[res[p][0]]+=1 if solved[res[p][0]]==1: sol+=1 def delete_l(p): global wa,sol,solved,pena if res[p][1]=="WA": wa[res[p][0]][0]-=1 if wa[res[p][0]][0]==0: wa[res[p][0]].popleft() if len(wa[res[p][0]])!=0: pena-=1 else: wa[res[p][0]].popleft() solved[res[p][0]]-=1 if solved[res[p][0]]==0: sol-=1 else: pena+=wa[res[p][0]][0] def add_r(p): global wa,sol,solved,pena if res[p][1]=="WA": if len(wa[res[p][0]])==0: wa[res[p][0]].append(1) elif wa[res[p][0]][-1]==0: wa[res[p][0]].append(1) else: wa[res[p][0]][-1]+=1 else: wa[res[p][0]].append(0) solved[res[p][0]]+=1 if solved[res[p][0]]==1: sol+=1 if len(wa[res[p][0]])>=2: pena+=wa[res[p][0]][-2] def delete_r(p): global wa,sol,solved,pena if res[p][1]=="WA": wa[res[p][0]][-1]-=1 if wa[res[p][0]][-1]==0: wa[res[p][0]].pop() else: wa[res[p][0]].pop() solved[res[p][0]]-=1 if solved[res[p][0]]==0: sol-=1 def fix(): return sol,pena N,M,Q=map(int,input().split()) res=[list(input().split()) for i in range(N)] for i in range(N): res[i]=(int(res[i][0])-1,res[i][1]) mo=MoAlgorithm(N) for i in range(N): L,R=map(int,input().split()) mo.add_query(L-1,R) wa=[deque() for i in range(M)] solved=[0]*N sol=0 pena=0 for i in mo.solve(add_l,delete_l,add_r,delete_r,fix): print(*i)