#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+5;
int n,m,T,x,y,k;
struct node{
int l,r,val,lazy;
} Tr[N*4];
void build(int u,int l,int r){
Tr[u] = {l,r,1,0};
if(l == r){
return;
}
int mid = (l+r)>>1;
build(u<<1,l,mid);
build(u<<1|1,mid+1,r);
}
int change(int x){
return pow(2,x-1);
}
int js(int x){
int sum = 0;
while(x){
sum += x&1;
x>>=1;
}
return sum;
}
void pushup(int u){
Tr[u].val = Tr[u<<1].val | Tr[u<<1|1].val;
}
void pushdown(int u){
if(Tr[u].lazy){
Tr[u<<1].val = Tr[u].lazy;
Tr[u<<1|1].val = Tr[u].lazy;
Tr[u<<1].lazy = Tr[u].lazy;
Tr[u<<1|1].lazy = Tr[u].lazy;
Tr[u].lazy = 0;
}
}
void update(int u,int x,int y,int k){
if(x>Tr[u].r || y < Tr[u].l) return;
if(x <= Tr[u].l && y >= Tr[u].r){
Tr[u].val = change(k);
Tr[u].lazy = change(k);
return;
}
pushdown(u);
update(u<<1,x,y,k);
update(u<<1|1,x,y,k);
pushup(u);
}
int query(int u,int x,int y){
if(x>Tr[u].r || y < Tr[u].l) return 0;
if(x <= Tr[u].l && y >= Tr[u].r){
return Tr[u].val;
}
pushdown(u);
int t = 0;
t |= query(u<<1,x,y);
t |= query(u<<1|1,x,y);
pushup(u);
return t;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n>>m>>T;
build(1,1,n);
while(T--){
char op; cin>>op;
if(op == 'C'){
cin>>x>>y>>k;
if(x > y) swap(x,y);
update(1,x,y,change(k));
}else{
cin>>x>>y;
if(x > y) swap(x,y);
cout<<js(query(1,x,y))<<endl;
}
}
return 0;
}