#C8780. Counting Palindromes in a List of Words

    ID: 52800 Type: Default 1000ms 256MiB

Counting Palindromes in a List of Words

Counting Palindromes in a List of Words

You are given a list of words. A word is said to be a palindrome if it reads the same forwards and backwards (i.e. \( s = s^R \), where \( s^R \) is the reverse of \( s \)). Your task is to count the number of occurrences of each palindrome in the list. Only words that are palindromes should be counted and printed.

The order of the output should reflect the order in which the palindromes first appear in the input.

inputFormat

The input is read from stdin and consists of:

  • An integer \( n \) on the first line, representing the number of words.
  • \( n \) subsequent lines, each containing a single word.

outputFormat

Print to stdout each palindrome along with its frequency. Each palindrome and its count should be printed on a separate line, with the word and frequency separated by a space. If no palindromic word exists, output nothing.

## sample
2
racecar
hello
racecar 1

</p>