#Lutece0582. Can You Help God Wu

Can You Help God Wu

Migrated from Lutece 582 Can You Help God Wu

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

There is a boy named God Wu in UESTC ACM team. One day he is asked to finish a task. The task is that he has to paint a wall as the given pattern. The wall can be represented as a 2×n2 \times n grid and each grid will be painted only one color. You know God Wu is a God, so he has a brush which could paint a rectangular area of the wall at a single step. As we all know, the paint could be overlap and the newly painted color will replace the older one.

God Wu is so lazy that he always want to finish something in the least steps. At first, the wall was not painted until God Wu paint some colors on it. For a given pattern of the wall, God Wu has to find out the minimum possible number of painting steps to make the wall the same as the given pattern.

Input

In the input file, the first line contains the number of test cases.

For each test case, the first contains only one integer n(1n8)n (1 \leq n \leq 8) indicating the length of the wall.

Then follows two lines, denoting the expected pattern of the wall. Every grid is painted by a color which is represented by a single capital letter. You can see the Input Sample for more details.

Output

For each test case, output only one integer denoting the minimum number of steps.

Samples

3
3
ABA
CBC
3
BAA
CCB
3
BBB
BAB
Case #1: 3
Case #2: 3
Case #3: 2

Resources

UESTC Training for Search Algorithm