#include using namespace std; #define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<int(a);) #define rep(i,n) repi(i,0,n) #define per(i,n) peri(i,0,n) #define all(c) begin(c),end(c) #define mp make_pair #define mt make_tuple using uint=unsigned; using ll=long long; using ull=unsigned long long; using vi=vector; using vvi=vector; using vl=vector; using vvl=vector; using vd=vector; using vvd=vector; using vs=vector; templatebool chmin(T& a,const U& b){return a>b?(a=b,1):0;} templatebool chmax(T& a,const U& b){return a void print_vars(ostream& os,const Car& car,const Cdr&... cdr){ print_vars(os< ostream& operator<<(ostream& os,const pair& p){ return os<<'('< void print_tuple(ostream&,const Tuple&){} template void print_tuple(ostream& os,const Tuple& t){ os<(t)<<(sizeof...(Cdr)?",":""); print_tuple(os,t); } template ostream& operator<<(ostream& os,const tuple& t){ print_tuple<0,Args...>(os<<'(',t); return os<<')'; } template basic_ostream& operator<<(basic_ostream& os,const C& c){ os<<'['; for(auto i=begin(c);i!=end(c);++i) os<<(i==begin(c)?"":" ")<<*i; return os<<']'; } constexpr int INF=1e9; constexpr int MOD=1e9+7; constexpr double EPS=1e-9; int main() { #ifndef _GLIBCXX_DEBUG ios_base::sync_with_stdio(false); cin.tie(nullptr); constexpr char endl='\n'; #endif for(int n,k,q;cin>>n>>k>>q&&n|k|q;){ vector as(q); vector bs(q),cs(q); rep(i,q) cin>>as[i]>>bs[i]>>cs[i],bs[i]--,cs[i]--; vi rflg(n),cflg(n); int rcnt=n,ccnt=n; vl res(k); per(i,q) if(as[i]=='R'){ if(!exchange(rflg[bs[i]],true)){ res[cs[i]]+=ccnt; rcnt--; } } else{ if(!exchange(cflg[bs[i]],true)){ res[cs[i]]+=rcnt; ccnt--; } } res[0]+=(ll)n*n-accumulate(all(res),0ll); rep(i,k) cout<