Scheduling Two Meetings

시간 제한1초메모리 제한2048 MB

요약
모든 심판이 두 회의 중 적어도 하나에 대면으로 참석하도록 두 시간대를 고르고, 둘 다 참석하는 심판 수가 최대인 쌍을 찾는다.
난이도

보통10점 중 6점

유형
비트 연산, 완전 탐색, 해시맵
정답자
아직 제출이 없습니다

문제

You are the chief judge of the International Collegiate Quiz Contest (ICQC) this year. You want to hold judge meetings twice for preparing the problem set of the contest. You proposed candidate schedules for the meetings, and all the judges answered for each of the time slots whether they would attend the meeting on-site or remotely via a video conference tool.

You have to choose a pair of two distinct time slots, so that every judge attends at least one of the two meetings on-site. When there are multiple such pairs, you’d like to choose one with the largest number of judges attending both meetings on-site. If multiple pairs are still equally desirable with these criteria, one with the earlier first meeting is preferred. If there still remain multiple pairs with the same time slot for the first meeting, the one with the earliest second meeting should be chosen.

입력

The input consists of a single test case of the following format.

 nn mm 

 a_1,1a\_{1,1} ⋯\cdots a_1,ma\_{1,m} 

 ⋮\vdots 

 a_n,1a\_{n,1} ⋯\cdots a_n,ma\_{n,m} 

Two integers nn and mm are given in the first line. The first integer nn (2≤n≤2×1052 ≤ n ≤ 2 \times 10^5) is the number of candidate time slots. Here, the candidate time slots are numbered 11 through nn, and smaller numbers mean earlier time slots. The second integer mm (2≤m≤202 ≤ m ≤ 20) is the number of judges.

In the following nn lines, a_i,ja\_{i,j} is either a character Y indicating that the jj-th judge attends a meeting at the ii-th candidate time slot on-site, or a character N indicating remote attendance.

출력

Output a line containing the two time slot numbers of the most preferable choice, separated by a space, with the earlier time slot first. If there are no pairs of time slots satisfying the condition, output No.

예제5

  1. 예제 1

    입력
    4 3
    NNY
    YYN
    YNY
    NYY
    
    예상 출력
    2 3
    
  2. 예제 2

    입력
    3 6
    NNNYYY
    YYNYYN
    YYYNNN
    
    예상 출력
    1 3
    
  3. 예제 3

    입력
    6 5
    NNNNN
    YNNNY
    YYNNN
    YYNNN
    NYYNY
    NNYYY
    
    예상 출력
    3 6
    
  4. 예제 4

    입력
    3 3
    YNN
    NYN
    NNY
    
    예상 출력
    No
    
  5. 예제 5

    입력
    4 4
    NYNN
    YNYY
    YNYN
    NNYY
    
    예상 출력
    1 2