#include <fstream>
#include <iostream>
#include <string>
#include <cstring>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <ctime>
#include <assert.h>
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define eps 1e-8
#define M_PI 3.141592653589793
typedef long long ll;
const ll mod=1000000007;
const int inf=0x7fffffff;
ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
using namespace std;
int M[40][40],cnt;
char s[1024];
void draw(char *s,int& p,int r,int c,int len)
{
char ch=s[p++];
if(ch=='p'){
draw(s,p,r,c+len/2,len/2);
draw(s,p,r,c,len/2);
draw(s,p,r+len/2,c,len/2);
draw(s,p,r+len/2,c+len/2,len/2);
}
else if(ch=='f'){
for(int i=r;i<r+len;i++){
for(int j=c;j<c+len;j++){
if(M[i][j]==0){
M[i][j]=1;cnt++;
}
}
}
}
}
int main()
{
int T;cin>>T;
char s[1500];
while(T--){
cnt=0;
memset(M,0,sizeof(M));
for(int i=0;i<2;i++){
scanf("%s",s);
int p=0;
draw(s,p,0,0,32);
}
printf("There are %d black pixels.\n",cnt);
}
}
#include <iostream>
#include <string>
#include <cstring>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <ctime>
#include <assert.h>
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define eps 1e-8
#define M_PI 3.141592653589793
typedef long long ll;
const ll mod=1000000007;
const int inf=0x7fffffff;
ll powmod(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
using namespace std;
int M[40][40],cnt;
char s[1024];
void draw(char *s,int& p,int r,int c,int len)
{
char ch=s[p++];
if(ch=='p'){
draw(s,p,r,c+len/2,len/2);
draw(s,p,r,c,len/2);
draw(s,p,r+len/2,c,len/2);
draw(s,p,r+len/2,c+len/2,len/2);
}
else if(ch=='f'){
for(int i=r;i<r+len;i++){
for(int j=c;j<c+len;j++){
if(M[i][j]==0){
M[i][j]=1;cnt++;
}
}
}
}
}
int main()
{
int T;cin>>T;
char s[1500];
while(T--){
cnt=0;
memset(M,0,sizeof(M));
for(int i=0;i<2;i++){
scanf("%s",s);
int p=0;
draw(s,p,0,0,32);
}
printf("There are %d black pixels.\n",cnt);
}
}