Consider a square matrix of size $$$n \times n$$$ consisting of non-negative integers. The matrix is symmetric with respect to the main diagonal, and the main diagonal itself contains only zeroes. Such a matrix is called wooden if there is an undirected tree $$$T$$$ on $$$n$$$ vertices with edges of positive lengths such that each cell $$$(i, j)$$$ of the matrix contains the distance between vertices $$$i$$$ and $$$j$$$ in this tree.
You are given a matrix. Check if it is wooden.
The first line contains an integer $$$n$$$: the size of the matrix ($$$1 \le n \le 1000$$$). Each of the following $$$n$$$ lines contains $$$n$$$ integers $$$d_{i,j}$$$: the elements of the matrix ($$$0 \le d_{i,j} \le 10^9$$$). The matrix is symmetric with respect to the main diagonal. There are zeros on the main diagonal and strictly positive integers outside it.
Print "Yes" or "No" depending on whether the matrix is wooden. Letter case does not matter.
30 1 31 0 23 2 0
Yes
30 1 31 0 13 1 0
No