#include <iostream>
#include <bits/stdc++.h>
#define len 32
#define maxn 1024+10
using namespace std;
bool buf[len][len];
int cnt;//计数
/**
2 1
3 4
**/
void draw(string s,int& p,int r,int c,int w)
{
char ch = s[p++];//不用判断p的范围,最后一个一定非黑即白,会自行退出
if(ch == 'p')
{
draw(s,p,r,c+w/2,w/2);//1
draw(s,p,r,c,w/2);//2
draw(s,p,r+w/2,c,w/2);
draw(s,p,r+w/2,c+w/2,w/2);
}
else if(ch == 'f')//黑色,画满
{
for(int i = r;i<r+w;i++)
{
for(int j = c;j<c+w;j++)
{
if(!buf[i][j])
{
buf[i][j] = 1;
cnt++;
}
}
}
}
}
int main()
{
int T;
cin>>T;
while(T--)
{
string s;
memset(buf,0,sizeof(buf));
cnt = 0;
for(int i = 0;i<2;i++)
{
cin>>s;
int p = 0;
draw(s,p,0,0,len);
}
cout<<"There are "<<cnt<<" black pixels."<<endl;
}
return 0;
}
/**
3
ppeeefpffeefe
pefepeefe
peeef
peefe
peeef
peepefefe
**/