#C13972. Filter Palindromes

    ID: 43569 Type: Default 1000ms 256MiB

Filter Palindromes

Filter Palindromes

You are given a list of words. A word is considered a palindrome if it reads exactly the same backward as forward. The check is case-sensitive and spaces are treated as normal characters. For example, "racecar" is a palindrome, but "nurses run" is not, because when reversed it does not match exactly.

Task: Read an integer n representing the number of words, followed by n lines each containing a word. Print all the palindromic words in the order they appear in the input, separated by a single space. If no words are palindromic, output an empty line.

The palindrome condition can be formally defined using the following equation in \( \LaTeX \):

\[ \text{word} = \text{reverse(word)} \]

inputFormat

The input is read from standard input (stdin) and has the following format:

  • The first line contains an integer \( n \) (\( 0 \leq n \leq 10^5 \)), representing the number of words.
  • The next \( n \) lines each contain a word. Words may include spaces and are considered as-is for the palindrome check.

outputFormat

Print the palindromic words in one line, separated by a single space. If there are no palindromic words, output an empty line.

## sample
3
madam
racecar
deified
madam racecar deified