2021 South Central USA Regional Contest — Division 1

Start

2022-03-05 13:00 CST

2021 South Central USA Regional Contest — Division 1

End

2022-03-05 18:00 CST
Contest is over.

Problem E
Fail Them All!

You are an instructor for an algorithms course, and your students have been saying mean things about you on social media. Those jerks! Being a vengeful and dishonest instructor, you are going to make them pay.

You have given your students a True/False exam. For each question, each student is allowed to either answer the question or leave the question blank. Each student has answered at least two questions. You want to make sure that every student fails the test, so you are going to alter the answer key so that no student gets more than one answer correct.

Is there an answer key such that every person has at most one submitted answer that is correct? If so, compute the lexicographically minimal such answer key.

Input

The first line of input contains two integers n (1 ≤ n ≤ 100) and k (2 ≤ k ≤ 100), where $n$ is the number of students in the class, and k is the number of questions on the test.

Each of the next n lines contains a string s (|s| = k, s ∈ {T, F, X}*), which are the answers to the questions, in order, for each student, where 'T' means True, 'F' means False, and 'X' means the student didn’t answer the question. Every student’s answers will have at least two which are not 'X'.

Output

If such an answer key can be constructed, output a string of length k consisting of only the characters 'T' and 'F', which is the answer key. If more than one such key is possible, output the one which comes first alphabetically (F < T$). If no such key exists, instead output -1.

Sample Input 1 Sample Output 1
3 3
FFX
XFF
FXF
FTT
Sample Input 2 Sample Output 2
3 3
FTX
XFT
TXF
FFF
Sample Input 3 Sample Output 3
4 3
TTX
XTT
TXT
FFF
-1