eolymp
bolt
Try our new interface for solving problems
Problems

DNA Robot

DNA Robot

Recent advances in DNA synthesis technology allowed for an experiment to create biorobots.

To facilitate the task of creating software to control robots, it was decided that their DNA will consist of m = 2n symbols for some n2. In addition, for technical reasons it is not an ordinary string, and cyclic, i.e. it can start reading from any position.

One of the goals of the experiment is to study mutations biorobots. As a result of prolonged observations, it was found many different kinds of robots. To understand the process of mutation scientists need to solve the following problem. For the DNA of two robots is required to determine the coefficient of similarity. It is calculated as the maximum number of matching characters in the best combination of DNA. The more identical symbols, the better the alignment.

Required to write a program that finds the best combination of the two DNA.

Input

The first line contains a single number m (4m131072). The next two lines contain DNA of two robots. Both DNA - a string consisting of exactly m characters from the set {'A', 'C', 'G', 'T'}.

Output

Print two numbers - the maximum number of matching symbols and the value of the optimal shift - a non-negative number of characters the second DNA to be transferred from the end of the line to the beginning to achieve the best combination.

Time limit 3 seconds
Memory limit 128 MiB
Input example #1
16
ACGTACGTACGTACGT
CGTACGTACGTACGTC
Output example #1
15 1
Author Gukov Dmitriy
Source Winter School, Kharkov, 2011, Day 2