Word Game
Two players are engaged in the following game:
The first player thinks of a word (W) and informs the second player of its length. The second player then attempts to guess the word by proposing words (G_i) of the same length. For each guessed word, the first player indicates whether the number of positions where the letters in (G_i) match those in the same positions of (W) is even or odd. This process continues until the second player successfully identifies the word (W).
Given the guessed words (G_i) and the corresponding responses, determine the possible word(s) (W) that the first player might have thought of.
In this context, a "word" is defined as any sequence of uppercase Latin letters.
Input
The first line of the input contains two non-negative integers (N) and (M) — the number of guessed words for which the number of matches is even, and the number of guessed words for which it is odd, respectively. The total number of guessed words satisfies (1 N + M 64).
The second line lists (N) words of the same length, composed of uppercase Latin letters — these are the words for which the number of matches is even.
The third line lists (M) words of the same length, composed of uppercase Latin letters — these are the words for which the number of matches is odd.
All words in both lines have the same length, ranging from 1 to 9 characters. Additionally, it is guaranteed that the number of possible words (W) in each test does not exceed 1000.
Output
On the first line of the output, print the number (K) — the count of different words that the first player could have thought of. On the second line, print all these words in lexicographical order, separated by spaces. The words should consist of uppercase Latin letters.