#include #include #include #include #include #include #include #include #include #define rep(i,e) for(int i=0;i<(e);i++) #define rep1(i,e) for(int i=1;i<=(e);i++) #define repx(i,x,e) for(int i=(x);i<=(e);i++) #define pii pair #define X first #define Y second #define PB push_back #define MP make_pair #define mset(var,val) memset(var,val,sizeof(var)) #define scd(a) scanf("%d",&a) #define scdd(a,b) scanf("%d%d",&a,&b) #define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c) #define IOS ios::sync_with_stdio(false);cin.tie(0) using namespace std; typedef long long ll; template void test(T a){cout< void test(T a,T2 b){cout< void test(T a,T2 b,T3 c){cout<> n >> m >> k; rep(i,n){ cin >> s; int x = 0; rep(j,m){ if(s[j] == 'A'){ x ^= 1<= k) ++res; } printf("%d\n", res); } int main() { #ifdef local freopen("in.txt","r",stdin); #endif // local IOS; int t; // scd(t); cin >> t; for(;t--;){ work(); } // work(); }