Personality Test
시간 제한3초메모리 제한1024 MB
n명의 답안 문자열이 주어질 때, 최소 k개 문항에서 같은 답을 한 유사한 두 학생을 찾고, 두 번째 번호가 가장 작은 쌍을 출력한다.
문제
There are students taking a personality test consisting of questions. The students are numbered from to and the questions are numbered from to . For each question, each student can either answer it with a single uppercase Latin character (A–Z) or not answer it. Let be a string of characters representing the answers of student , where the -th character of is an uppercase Latin character if they answered question , or a period (.) if they did not.
Two students are considered similar if there is a set of at least questions where both students answered all questions in the set, and for each question in the set, they answered it with the same answer.
For example, let , , , BBC, ..C, and .BC. In this example, students and are similar since they answered questions and with the same answer, while students and are not similar since they answered only question with the same answer.
You want to find a pair of integers such that and students and are similar, or determine if there is no such pair. If there is more than one pair, find the one with the smallest . If there is still more than one pair, find the one with the largest .
입력
The first line of input contains three integers , , and (; ; ). Each of the next lines contains a string of characters. The -th line contains the string .
출력
Output one line containing the integers and representing the pair of similar students as mentioned in the problem statement, or just the integer -1 if there is no such pair.