Under construction

Still being built. Things may change

Gene Combination

Interview

Time limit1sMemory limit512 MB

Summary
Given N genes made of two uppercase letters, find which letters can be the phenotype (the larger letter) of a gene formed by combining two different genes, and list them in order.
Level

Medium4 of 10

Topics
Implementation, Math
Solved
No attempts yet

Problem

Students at Seoul National University of Science and Technology found a gene from an unfamiliar organism during an experiment. The gene is described by two traits, and each trait is written as an uppercase letter. Genes can be combined with other genes. When two genes are combined, the first trait of the first gene and the second trait of the second gene are joined to form a second-generation gene. Among the letters in a gene's two traits, the letters that are alphabetically equal to or greater than the others are called the gene's phenotype.

Given NN first-generation genes, each one can be combined with every other distinct first-generation gene. Find how many letters can appear as phenotypes of the second-generation genes produced by these combinations, and find those letters.

Input

The first line contains the number of genes NN. (2≤N≤100 0002 \le N \le 100\,000)

The second line contains the NN first-generation genes, separated by spaces.

Output

On the first line, print the number of letters that can be phenotypes of the second-generation genes.

On the second line, print those phenotype letters in alphabetical order, separated by spaces.

Examples1

  1. Example 1

    Input
    3
    AB DC XP
    
    Expected output
    4
    C D P X