QOJ.ac

QOJ

Time Limit: 1.0 s Memory Limit: 256 MB Total points: 100 Hackable ✓

#9246. Dominating Point

الإحصائيات

You’re given a complete directed graph $G$ with $n$ vertices. We call a vertex $u$ dominating if for every $v \neq u$, there either exists an edge $(u \to v)$ or there exists a vertex $w$ satisfying $(u \to w)$ and $(w \to v)$.

You now need to find 3 distinct dominating vertices of the given graph. If there are less than 3 dominating vertices, output NOT FOUND.

Input

The first line of input contains one integer $n$ ($1 \le n \le 5000$).

The next $n$ lines of input contain a binary string $s_i$ each. There exists edge $(u \to v)$ if the $v$-th character of $s_u$ is $1$; otherwise, there is no such edge. It is guaranteed that exactly one of $s_{i,j} = 1$ and $s_{j,i} = 1$ holds for every $1 \le i < j \le n$ and $s_{i,i} = 0$ for every $1 \le i \le n$.

Output

The first line of output contains three integers $a, b, c$, denoting the answer you’ve found, or NOT FOUND, if there are not enough dominating vertices.

Examples

Input 1

6
011010
000101
010111
100001
010100
100010

Output 1

3 1 4

Input 2

3
011
001
000

Output 2

NOT FOUND

Input 3

3
010
001
100

Output 3

1 3 2

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.