#include using namespace std; const int N=2e5+10; pairans[N],tree[N],f[N]; vector>w[N]; int n,m,q,x,y; int a[N],b[N]; char s[10]; void add(int x,pairy){ while (x<=n){ tree[x].first+=y.first; tree[x].second+=y.second; x+=(x&(-x)); } } pair solve(int x){ pairans=make_pair(0,0); while (x){ ans.first+=tree[x].first; ans.second+=tree[x].second; x-=(x&(-x)); } return ans; } int main(){ scanf("%d%d%d",&n,&m,&q); for (int i=1;i<=n;i++){ scanf("%d%s",&a[i],s); if (s[0]=='A') b[i]=1; else b[i]=0; } for (int i=1;i<=q;i++){ scanf("%d%d",&x,&y); w[x].push_back(make_pair(y,i)); } for (int i=n;i>=1;i--){ if (b[i]){ if (f[a[i]].first){ add(f[a[i]].first,make_pair(-1,-f[a[i]].second)); } f[a[i]].first=i; f[a[i]].second=0; add(i,make_pair(1,0)); }else{ if (f[a[i]].first){ add(f[a[i]].first,make_pair(0,1)); } } for (int j=0;j