402587: GYM100814 B Unlucky Teacher

Memory Limit:1024 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

B. Unlucky Teachertime limit per test1 secondmemory limit per test1024 megabytesinputstandard inputoutputstandard output

Ali is a teacher in one of Kuwait universities. Last week he made a multi-choice test for his students. After the test, he marked some papers before collecting all papers and going home. However, he discovered that he forgot the solution key at the university. He is sure that he didn't make any mistake in correcting papers, so in order to complete the correction process, he decided to extract the solution key from the papers that have already been marked.

Ali knows that each question should have one and only one correct choice, can you help him with extracting the correct answers for all the questions?

Input

The first line of the input is a single integer T, the number of test cases. Each test case will consist of several lines. The first line contains 2 integers separated by a single space: (1 ≤ Q ≤ 100 and 0  ≤ M ≤ 100) representing the number of questions in the test, and the number of the corrected papers, respectively. Each of the next M lines will contain 2Q upper case letters separated by single spaces: qi ai ( {'A','B','C','D'} and {'T','F'}) representing the student answer for the ith question (from a corrected paper) and the status of the student answer 'T' if it is True or 'F' if it is False.

Output

For each test case, print a single line contains Q characters separated by single spaces: {'A','B','C','D','?'}) representing the correct answer of ith question that could be extracted from the given corrected papers or '?' in case it could not be determined.

ExamplesInput
2
3 2
A F B F C T
B T C F D F
1 3
A F
B F
C F
Output
B ? C
D

加入题单

上一题 下一题 算法标签: