PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#FW0000044. Bạn bè tiềm năng (Possible Friends)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Bạn bè tiềm năng (Possible Friends)

Possible Friends

Source: SPOJ

Version: Phuoc Hung OJ Extended

Problem Statement

Two non-friends are potential friends if they share a direct friend. Find the person with the maximum number of potential friends; break ties by smallest ID.

Input

Integer nn, followed by an n×nn\times n Y/N friendship matrix; persons are 0-indexed.

Output

Print the 0-based index of the chosen person and their potential-friend count.

Subtasks

  • Subtask 1 (40 points): n≤10n\le10; 1≤n≤501\le n\le50, symmetric matrix with N on the diagonal; Y indicates direct friendship.
  • Subtask 2 (60 points): 1≤n≤501\le n\le50, symmetric matrix with N on the diagonal; Y indicates direct friendship.

Examples

Input

3
NYN
YNY
NYN

Output

0 1

Explanation

People 0 and 2 are not friends but share person 1. Each has one potential friend; the smallest index 0 wins the tie.