Task
Given a sequence of natural numbers, each with at most digits, you need to answer the following questions:
- How many numbers in the sequence are palindromes?
- How many numbers in the sequence could be palindromes if their digits were rearranged suitably?
- Find the maximum number of palindromes with at least two digits that could be obtained if we rearrange all the digits of the numbers in the sequence to form new numbers, not necessarily the ones in the sequence and not necessarily numbers.
Input data
The first line contains , the number of numbers in the sequence. The next line contains the values of the sequence.
Output data
The first line should contain the number of palindromes in the sequence, the second line should contain the number of numbers in the sequence that could be palindromes if their digits were rearranged suitably, and the third line should contain the maximum number of palindromes that could be obtained if we rearrange all the digits of the numbers in the sequence to form new numbers.
Constraints and clarifications
- ;
- The numbers in the sequence have at most digits and at least digits;
- After rearrangements, numbers are not allowed to start with the digit zero;
- A palindrome is a number that reads the same if its digit order is reversed. For example, is a palindrome, but is not.
- Requirement 1 is worth 30 points, requirement 2 is worth 30 points, and requirement 3 is worth 40 points. To receive points for separate requirements, you must follow the output format presented above.
Example 1
stdin
3
402 440 323
stdout
1
2
3
Explanation
is the only palindrome in the sequence.
Besides , would also become a palindrome if its digits were rearranged suitably, since is a palindrome.
If we rearrange the digits of the numbers in the sequence to form the numbers , , , and , we get palindromes with at least two digits, which is the maximum possible answer.
Example 2
stdin
7
161 3933595 49294 953393 732 393 888
stdout
4
5
12