Just Implementation

3

1 votes
Easy
Problem

Bill's implementation skills are also to be tested. He comes across a grid (N x M) filled with alphabets. He has to mark all the letters which appear more than once in a row or column. In other words, a letter should only be marked if and only if the corresponding column or row has its frequency of occurrence more than 1. All such letters are marked simultaneously.

From the remaining unmarked grid he has to make the lexicographically largest string possible. If the grid becomes empty (it has no unmarked elements left) after the operation, print "Empty".

Constraints:

1 ≤ ≤ 5

1 ≤ N,M ≤ 1000

Grid consists of lower case English letters (a-z)

Input Format:

The first line contains the number of test cases T.

The first line of each test case contains two integers N and M. Next N lines contain M lowercase English letters each. 

Output Format:

Print the lexicographically largest string possible. If grid becomes empty print "Empty".

 

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?