Given two length-N strings of W and B, find the minimum number of swap-two-positions and flip-one-piece operations to turn the start into the target.
Medium5GreedyMathStringNo attempts yetTime limit2sMemory limit256 MBSehee likes robots. In her robotics club she built one out of a camera, sensors, a Raspberry Pi, and a gripper, and she uses it for a task called Othello rearrangement. An Othello piece is black on one face and white on the other. Sehee wants the pieces that lie on the board at the start to end up exactly like a given target arrangement.
The robot can perform one of the two operations below, one at a time.
| Start | Target |
|---|---|
| WBBWW | WBWBW |
For the arrangement above, turning over the third piece and the fourth piece reaches the target in two operations. Swapping the third piece with the fourth piece instead reaches the target in one operation.
Given the starting arrangement and the target arrangement, write a program that finds the minimum number of operations needed to reach the target arrangement.
Input is read from standard input. The first line contains the number of test data T. The first line of each test data contains the number of Othello pieces N (1≤N≤100000). The second line holds the starting arrangement and the third line holds the target arrangement, each a string of length N. A piece showing its white face is written as W, and a piece showing its black face is written as B.
Output is written to standard output. For each test data, print on one line the minimum number of operations that turns the starting arrangement into the target arrangement.