string@S,@T,a[4]{};rep(s,S)rep(t,T){setX{s,t};a[X.count('A')*2+X.count('B')]++;}wt(a[2],a[1],a[3],*a);