You are given three strings \(a\), \(b\) and \(c\) each of length \(n\) consisting of lower case English letters. The difference between the three strings is defined as \(\sum\limits_{i=1}^n \ |a[i]-b[i]|+|a[i]-c[i]|\) where \(|a[i]-b[i]|\) and \(|a[i]-c[i]|\) are the absolute differences between ASCII values of the characters at the position \(i\) in strings \(a,b\) and \(a,c\) respectively. However, the string \(a\) can be rotated cyclically (for example the rotations of the string \(xyz\) are \(xyz,zxy,yzx\)). There are a total of \(n\) possible rotations of a string of length \(n\).
Print the maximum and minimum difference of the three strings for all the possible rotations of the string \(a\).
Input format
First line: Single integer \(n\) (the length of the three strings)
Next three lines: Strings \(a,b\) and \(c\) respectively
Output Format:
Print two space-separated integers: the maximum and minimum difference of the three strings for all possible rotations of string \(a\).
Constraints
\(1 \le n \le 100000\)
The minimum difference is obtained when the first string is rotated cyclically once while the difference is maximum without any rotation.
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor