QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 32 MB Puntuación total: 10

#11668. Jasio

Estadísticas

Little Johnny has been given a very difficult task to solve. He has a list of words and must count how many of those words contain a palindrome longer than one character. A palindrome is a word that reads the same both forwards and backwards. Thus, the word "ala" is a palindrome. However, the word "kot" is not a palindrome, because reading it backwards sounds different — "tok". For example, the word "foo" contains a palindrome longer than one character — it is the sequence "oo", while the word "ftof" does not contain a palindrome longer than one character.

A certain problem has arisen. Since Johnny cannot read well yet, he does not distinguish the letter "i" from the letter "j", nor does he distinguish the letters "p", "b", and "d". When the letter "i" or "j" appears in a word, Johnny treats them as the same character. The same applies to "p", "b", and "d". Consequently, Johnny also considers the word "pod" to be a palindrome.

You need to write a program that will verify the solution Johnny provided.

Task

Write a program that:

  • reads a list of words for processing,
  • calculates the number of words in the input that contain any palindrome longer than one character,
  • calculates the number of words in the input that Johnny considers to contain any palindrome longer than one character,
  • prints both numbers.

Input

The first line contains a natural number $n$ — the number of words to process, $1 \le n \le 10\,000$. The following $n$ lines each contain exactly one word. The words consist only of lowercase English letters. The length of any word does not exceed 200 characters.

Output

Your program should print exactly two lines, each containing one integer. The first line should contain the number of words containing a palindrome of at least two characters, while the second line should contain the result obtained by little Johnny.

Examples

Input 1

4
foo
bar
ala
pod

Output 1

2
3

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.