Yo`nalishlar
Hozirda online

Statistika

Masalalar soni: 909

Foydalanuvchilar soni: 8824

Jo'natishlar soni: 714622

Muhokama yozuvlari: 4541

Yangiliklar soni: 98

Yangiliklar izohlari: 1177


So'ngi izohlar

755. Is it a Tree?
Vaqt limiti: 1 sekund
Xotira limiti: 128 MB

Tree is a connected and without cyclic graph. Undirected graph without loops and multiple edges is given with the adjacency matrix. Determine whether the graph is a tree.

Input

The first line contains the number of vertices n (1  n ≤ 400) in the graph. In the next lines the adjacency matrix of size n×n is given, where 1 denotes the presence of an edge, and 0 its absence. The matrix is symmetric with respect to the main diagonal.

Output

Print the message YES, if the graph is a tree, and NO otherwise.

Samples

Input

Output

1

3

0 1 0

1 0 1

0 1 0

YES

2

4

0 1 0 0

1 0 0 0

0 0 0 1

0 0 1 0

NO

 

Tayyorladi: Azat Yusupov
Text from: e-olimp.com
Mening urinishlarim(0) Muhokama (3) Jo'natish Eng yaxshi yechimlar Barcha muvaffaqiyatli urinishlar(28) Barcha urinishlar(112)