We consider a binary image of size 32x32 (1024 pixels). We perform sucessive subdivisions following the pattern
+---+---+
| 2 | 1 |
+---+---+
| 3 | 4 |
+---+---+
We then form a quadtree to represent the image. Given two in depth traversals of two quadtrees, give the amount of black pixels on the image represented by the sum of the two corresponding images.
- The sum of two white pixels is a white pixel.
- The sum of a white pixel and a black pixel is a black pixel.
- The sum of two black pixels is a black pixel.
Input
N cases. We will suppose every traversal is representative of a valid quadtree.
- 50 ≤ N ≤ 500
Examples
Input :
w
b
nnwbbbnbbwbbnwbwb
b
nwnwwwwnwwbwnwbww
nnbwbwnwwbwbnwbww
Output :
1024
256
384