Personality Test

시간 제한3초메모리 제한1024 MB

요약
n명의 답안 문자열이 주어질 때, 최소 k개 문항에서 같은 답을 한 유사한 두 학생을 찾고, 두 번째 번호가 가장 작은 쌍을 출력한다.
난이도

보통10점 중 6점

유형
해시맵, 문자열, 조합론
정답자
아직 제출이 없습니다

문제

There are nn students taking a personality test consisting of mm questions. The students are numbered from 11 to nn and the questions are numbered from 11 to mm. For each question, each student can either answer it with a single uppercase Latin character (A–Z) or not answer it. Let S_iS\_i be a string of mm characters representing the answers of student ii, where the jj-th character of S_iS\_i is an uppercase Latin character if they answered question jj, or a period (.) if they did not.

Two students are considered similar if there is a set of at least kk 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 n=3n = 3, m=3m = 3, k=2k = 2, S_1=S\_1 = BBC, S_2=S\_2 = ..C, and S_3=S\_3 = .BC. In this example, students 11 and 33 are similar since they answered questions 22 and 33 with the same answer, while students 22 and 33 are not similar since they answered only question 33 with the same answer.

You want to find a pair of integers (a,b)(a, b) such that a<ba < b and students aa and bb are similar, or determine if there is no such pair. If there is more than one pair, find the one with the smallest bb. If there is still more than one pair, find the one with the largest aa.

입력

The first line of input contains three integers nn, mm, and kk (2≤n≤50002 ≤ n ≤ 5000; 1≤m≤30001 ≤ m ≤ 3000; 1≤k≤51 ≤ k ≤ 5). Each of the next nn lines contains a string of mm characters. The ii-th line contains the string S_iS\_i.

출력

Output one line containing the integers aa and bb representing the pair of similar students as mentioned in the problem statement, or just the integer -1 if there is no such pair.

예제4

  1. 예제 1

    입력
    3 3 2
    BBC
    ..C
    .BC
    
    예상 출력
    1 3
    
  2. 예제 2

    입력
    3 3 1
    BBC
    ..C
    .BC
    
    예상 출력
    1 2
    
  3. 예제 3

    입력
    3 3 3
    BBC
    ..C
    .BC
    
    예상 출력
    -1
    
  4. 예제 4

    입력
    4 12 2
    GOOD.LUCK.IN
    WINNING.ICPC
    ASIA.PACIFIC
    CHAMPIONSHIP
    
    예상 출력
    2 3