Under construction

Still being built. Things may change

Forged Answers

Time limit3sMemory limit256 MB

Summary
Given three answer strings over A to D, choose one answer per question to maximize the lowest of the three scores.
Level

Medium7 of 10

Topics
Greedy, Binary search
Solved
No attempts yet

Problem

wen, dream, and moon did not score enough to pass the course, so all three had to take the make-up exam. The exam had nn multiple choice questions worth one point each, and every question offered the four choices A, B, C, and D. The three handed in their answer sheets for computer grading. After the exam their friend drazil checked the sheets and found that all three had answered every question wrong.

drazil feels sorry for them, so he decides to break into the teacher's computer and rewrite the standard answers. He may set the standard answer of each question to any of A, B, C, or D, and he wants the lowest of the three scores to be as high as possible.

For example, suppose the exam had 3 questions, wen answered ABC, dream answered BCD, moon answered CDA, and the original standard answers were DAB. All three were wrong on every question, so drazil rewrites the standard answers as CCC and each of them then has exactly one correct answer.

Given the three answer sheets, find the largest value that the minimum of the three scores can reach after drazil rewrites the standard answers. The original standard answers are not part of the input, because drazil picks a new answer for every question.

Input

The first line contains an integer TT (1≤T≤1001 \le T \le 100), the number of test cases.

Each test case takes four lines. The first line contains an integer nn (1≤n≤300001 \le n \le 30000), the number of questions. The next three lines give the answer sheets of wen, dream, and moon in that order. Each sheet is a string of nn characters drawn from A, B, C, and D, and its ii-th character is the answer written for question ii.

Output

For each test case, print one line with the largest value that the minimum of the three scores can reach.

Examples2

  1. Example 1

    Input
    2
    3
    ABC
    BCD
    CDA
    4
    AABC
    AACD
    BBAA
    
    Expected output
    1
    2
    
  2. Example 2

    Input
    2
    3
    AAA
    AAA
    BBB
    4
    AAAA
    AAAA
    BBBB
    
    Expected output
    1
    2