Okabe needs to renovate the Future Gadget Laboratory after he tried doing some crazy experiments! The lab is represented as an n by n square grid of integers. A good lab is defined as a lab in which every number not equal to 1 can be expressed as the sum of a number in the same row and a number in the same column. In other words, for every x, y such that 1 ≤ x, y ≤ n and a_{x}, y ≠ 1, there should exist two indices s and t so that a_{x}, y = a_{x}, s + a_{t}, y, where a_{i}, j denotes the integer in i-th row and j-th column.

Help Okabe determine whether a given lab is good!


-----Input-----

The first line of input contains the integer n (1 ≤ n ≤ 50) — the size of the lab. 

The next n lines contain n space-separated integers denoting a row of the grid. The j-th integer in the i-th row is a_{i}, j (1 ≤ a_{i}, j ≤ 10^5).


-----Output-----

Print "Yes" if the given lab is good and "No" otherwise.

You can output each letter in upper or lower case.


-----Examples-----
Input
3
1 1 2
2 3 1
6 4 1

Output
Yes

Input
3
1 5 2
1 1 1
1 2 3

Output
No



-----Note-----

In the first sample test, the 6 in the bottom left corner is valid because it is the sum of the 2 above it and the 4 on the right. The same holds for every number not equal to 1 in this table, so the answer is "Yes".

In the second sample test, the 5 cannot be formed as the sum of an integer in the same row and an integer in the same column. Thus the answer is "No".

Source: codeforces | Difficulty: EASY
Tags: Implementation


Solutions:
from itertools import *
n = int(input())
f = [list(map(int, input().split())) for _ in range(n)]
for (i, j) in product(list(range(n)), list(range(n))):
	x = f[i][j]
	if x == 1:
		continue
	if not any((a + b == x for (a, b) in product(chain(f[i][:j], f[i][j + 1:]), (f[k][j] for k in chain(list(range(i)), list(range(i + 1, n))))))):
		print('No')
		return
print('Yes')


n = int(input())
mat = []
for i in range(n):
	a = [int(x) for x in input().split()]
	mat.append(a)
isp = 1
for i in range(n):
	for j in range(n):
		if mat[i][j] == 1:
			continue
		isb = 0
		for k in range(n):
			for m in range(n):
				if mat[i][j] == mat[i][k] + mat[m][j]:
					isb = 1
		if isb == 0:
			isp = 0
			break
if isp > 0:
	print('Yes')
else:
	print('No')


def solution(l1):
	i = 0
	while i < len(l1):
		j = 0
		while j < len(l1):
			targ = l1[i][j]
			if targ != 1:
				l = 0
				while l < len(l1[i]):
					first = l1[i][l]
					n = 0
					while n < len(l1):
						second = l1[n][j]
						done = 0
						if second + first == targ:
							done = 1
							break
						n += 1
					if done:
						break
					else:
						pass
					l += 1
					if l == len(l1[j]):
						return 'NO'
			j += 1
		i += 1
	return 'YES'

def answer():
	n = int(input())
	l1 = []
	while n:
		l1.append([int(x) for x in input().split()])
		n -= 1
	print(solution(l1))
answer()


a = []
n = int(input())
c = []
f = 0
z1 = []
j = -1
for _ in ' ' * n:
	for i in map(int, input().split()):
		j += 1
		z1 += [i]
		if i != 1:
			c += [(f, j, i)]
	f += 1
	a += [z1]
	z1 = []
	j = -1
for _ in c:
	if not any((a[_[0]][i] + a[j][_[1]] == _[2] for i in range(n) for j in range(n))):
		print('NO')
		exit()
print('yes')


def d4c(lab, n):
	for i in range(n):
		for j in range(n):
			x = lab[i][j]
			if x == 1:
				continue
			f = 0
			for k in range(n):
				if k != i:
					for l in range(n):
						if l != j:
							if lab[i][l] + lab[k][j] == x:
								f = 1
								continue
			if f != 1:
				return 'No'
	return 'Yes'
n = int(input())
lab = []
for _ in range(n):
	lab.append(list(map(int, input().split())))
print(d4c(lab, n))


row = []
mat = []

def finder(x, i, j):
	flag = 0
	for b in range(0, n):
		for a in range(0, n):
			if mat[i][b] + mat[a][j] == x:
				flag = 1
				break
		if flag:
			break
	if flag:
		return 1
	else:
		return 0
n = int(input())
for i in range(0, n):
	row = [int(x) for x in input().split()]
	mat.append(row)
ans = 0
for i in range(0, n):
	for j in range(0, n):
		if mat[i][j] != 1:
			ans = ans + finder(mat[i][j], i, j)
		else:
			ans = ans + 1
if ans == n * n:
	print('Yes')
else:
	print('No')


n = int(input())
a = []
for i in range(n):
	a.append(list(map(int, input().split())))
for i in range(n):
	for j in range(n):
		if a[i][j] != 1:
			t = 1
			for x in range(n):
				for y in range(n):
					if a[i][x] + a[y][j] == a[i][j]:
						t = 0
			if t:
				exit(print('No'))
print('Yes')


n = int(input())
a = []
for _ in range(n):
	a.append(list(map(int, input().split())))
res = True
for i in range(n):
	for j in range(n):
		if a[i][j] != 1:
			res = False
			for k in range(n):
				for l in range(n):
					if a[i][j] == a[i][k] + a[l][j]:
						res = True
		if not res:
			print('No')
			exit(0)
print('Yes')


n = int(input())
k = []
for i in range(n):
	k.append(list(map(int, input().split())))
k1 = tuple(zip(*k))
m = []
for i in range(n):
	for j in range(n):
		if k[i][j] != 1:
			g = False
			for l in k[i]:
				for z in k1[j]:
					if l + z == k[i][j]:
						m.append(1)
						g = True
						break
				if g:
					break
		else:
			m.append(1)
if len(m) == n * n:
	print('Yes')
else:
	print('No')


from sys import stdin, stdout
import cProfile
printHeap = str()
test = False
memory_constrained = False

def display(string_to_print):
	stdout.write(str(string_to_print) + '\n')

def test_print(output):
	if test:
		stdout.write(str(output) + '\n')

def display_list(list1, sep=' '):
	stdout.write(sep.join(map(str, list1)) + '\n')

def get_int():
	return int(stdin.readline().strip())

def get_tuple():
	return map(int, stdin.readline().strip().split())

def get_list():
	return list(map(int, stdin.readline().strip().split()))
memory = dict()

def clear_cache():
	global memory
	memory = dict()

def cached_fn(fn, *args):
	global memory
	if args in memory:
		return memory[args]
	else:
		result = fn(*args)
		memory[args] = result
		return result
import math, copy

def calc(a, b, op):
	return a - b if op == '-' else a + b if op == '+' else a * b if op == 'X' or op == '*' else a // b

def chkGood(arr, i, j, n):
	g = False
	for i1 in range(n):
		if g:
			break
		if i1 == i:
			continue
		for j1 in range(n):
			if j1 == j:
				continue
			if arr[i1][j] + arr[i][j1] == arr[i][j]:
				g = True
				break
	return g

def main():
	n = get_int()
	arr = [[0 for _ in range(n)] for _ in range(n)]
	for i in range(n):
		arr[i] = get_list()
	good = True
	for i in range(n):
		if not good:
			break
		for j in range(n):
			ele = arr[i][j]
			if ele != 1:
				if not chkGood(arr, i, j, n):
					good = False
					break
	print('Yes') if good else print('No')
cProfile.run('main()') if test else main()


import math, sys, bisect, heapq
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
int1 = lambda x: int(x) - 1
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))
ilelec = lambda : map(int1, input().split())
alelec = lambda : list(map(int1, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])

def fun(A, B, x):
	for i in A:
		for j in B:
			if i + j == x:
				return True
	return False
A = []
n = int(input())
for i in range(n):
	C = alele()
	A.append(C)
B = list(zip(*A))
for i in range(n):
	for j in range(n):
		if A[i][j] != 1:
			if not fun(A[i], B[j], A[i][j]):
				f = 0
				Yy(0)
				exit(0)
Yy(1)


n = int(input())
A = []
for i in range(n):
	A += [list(map(int, input().split()))]
v = True
for i in range(n):
	for j in range(n):
		if A[i][j] != 1:
			f = False
			for x in range(n):
				for y in range(n):
					if A[x][j] + A[i][y] == A[i][j]:
						f = True
						break
				if f:
					break
			if not f:
				v = False
				break
	if not v:
		break
if v:
	print('Yes')
else:
	print('No')


n = int(input())
a = []
for i in range(n):
	a.append(list(map(int, input().split())))
ans = True
for i in range(n):
	if not ans:
		break
	for j in range(n):
		if a[i][j] == 1:
			continue
		flag = False
		for s in range(n):
			for t in range(n):
				if a[i][j] == a[i][s] + a[t][j]:
					flag = True
		if not flag:
			ans = False
			break
if ans:
	print('Yes')
else:
	print('No')


def is_good(matrix, n, i, j):
	if matrix[i][j] == 1:
		return True
	row = [matrix[i][s] for s in range(n) if s != j]
	col = [matrix[t][j] for t in range(n) if t != i]
	for r in row:
		for c in col:
			if r + c == matrix[i][j]:
				return True
	return False

def main():
	n = int(input())
	matrix = [[]] * n
	for i in range(n):
		matrix[i] = [int(_) for _ in input().split()]
	found = False
	for i in range(n):
		if found:
			break
		for j in range(n):
			if found:
				break
			found = not is_good(matrix, n, i, j)
	print('No' if found else 'Yes')
main()


n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
(x, m) = (0, 0)
flag = 0
l = []
for i in range(n):
	for j in range(n):
		if a[i][j] != 1:
			x += 1
			for k in range(n):
				if a[i][k] != a[i][j]:
					l.append(a[i][j] - a[i][k])
			for k in range(n):
				if a[k][j] in l:
					flag = 1
					break
			if flag == 1:
				m += 1
			del l[:]
			flag = 0
if m == x:
	print('Yes')
else:
	print('No')


from itertools import product
n = int(input())
A = [list(map(int, input().split())) for _ in range(n)]
for (i, j) in product(range(n), repeat=2):
	if A[i][j] > 1 and all((A[i][k] + A[m][j] != A[i][j] for (k, m) in product(range(n), repeat=2))):
		print('No')
		break
else:
	print('Yes')


def main():
	n = int(input())
	a = []
	for _ in range(n):
		a.append(list(map(int, input().split())))
	for i in range(n):
		for j in range(n):
			e = a[i][j]
			if e == 1:
				continue
			else:
				fl = False
				for i1 in range(n):
					for j1 in range(n):
						if a[i1][j] + a[i][j1] == e:
							fl = True
							break
					if fl:
						break
				if fl:
					continue
				else:
					print('No')
					return
	print('Yes')
main()


n = int(input())
x = []
for i in range(n):
	x.append(list(map(int, input().split())))
for i in range(n):
	for j in range(n):
		if x[i][j] != 1:
			r = 0
			for k in range(n):
				for l in range(n):
					if x[i][k] + x[l][j] == x[i][j]:
						r = 1
			if r == 0:
				print('No')
				exit()
print('Yes')


def solve(n, m):
	for i in range(n):
		line = m[i]
		for j in range(n):
			if m[i][j] == 1:
				continue
			column = [m[k][j] for k in range(n)]
			found = False
			for k in line:
				for t in column:
					if k + t == m[i][j]:
						found = True
						break
				if found:
					break
			if not found:
				return 'No'
	return 'Yes'

def main():
	n = int(input())
	m = [list(map(int, input().split())) for _ in range(n)]
	print(solve(n, m))
main()


def main():
	n = int(input())
	l = list((list(map(int, input().split())) for _ in range(n)))
	cols = list(map(set, zip(*l)))
	for row in l:
		for (t, col) in zip(row, cols):
			if t != 1:
				for a in row:
					if t - a in col:
						break
				else:
					print('No')
					return
	print('Yes')
main()


import sys
import time
import heapq
import collections
from io import StringIO
test_cases = [('\n3\n1 1 2\n2 3 1\n6 4 1\n', '\nYes\n'), ('\n3\n1 5 2\n1 1 1\n1 2 3\n', '\nNo\n')]

def solve():
	return 'TEST'

def debug(*args, **kwargs):
	print(*args, **kwargs, file=sys.stderr)

def check(rows, cols):
	for (i, row) in enumerate(rows):
		for (j, el) in enumerate(row):
			if el != 1:
				found = False
				for (k, add_in_row) in enumerate(row):
					add_in_col = el - add_in_row
					n = cols[j].get(add_in_col, 0)
					if k != j and (n > 0 and add_in_col != el or (n > 1 and add_in_col == el)):
						found = True
						break
				if not found:
					return False
	return True

def main():
	n = int(input())
	rows = []
	cols = []
	for i in range(n):
		rows.append([int(el) for el in input().split()])
	for i in range(n):
		d = {}
		for row in rows:
			d[row[i]] = d.get(row[i], 0) + 1
		cols.append(d)
	result = check(rows, cols)
	print('Yes' if result else 'No')

def test(s, check):
	s = s.strip()
	check = check.strip()
	sys.stdin = StringIO(s)
	sys.stdout = out = StringIO()
	start_time = time.time()
	try:
		main()
	finally:
		exec_time = time.time() - start_time
		sys.stdin = sys.__stdin__
		sys.stdout = sys.__stdout__
	out.seek(0)
	result = out.read().strip()
	status = 'SUCCESS' if result == check else 'FAILURE'
	message = 'status: {}, exec_time: {:.3f}'.format(status, exec_time)
	debug(message)

def test_all():
	for (s, check) in test_cases:
		test(s, check)
if len(sys.argv) > 1 and sys.argv[1] == '-t':
	test_all()
else:
	main()


n = int(input())
l = []
lc = []
for _ in range(n):
	lc.append([])
for _ in range(n):
	li = list(map(int, input().split()))
	l.append(li)
	for i in range(n):
		lc[i].append(li[i])
for i in range(n):
	for j in range(n):
		if l[i][j] != 1:
			co = 0
			for k in l[i]:
				for m in lc[j]:
					if k + m == l[i][j]:
						co = 1
			if co == 0:
				print('NO')
				exit()
print('YES')


n = int(input())
a = []
for i in range(n):
	a.append(list(map(int, input().split())))
for i in range(n):
	for j in range(n):
		if a[i][j] == 1:
			continue
		exist = False
		for x in range(n):
			for y in range(n):
				if a[x][j] + a[i][y] == a[i][j]:
					exist = True
					break
			if exist:
				break
		if not exist:
			print('No')
			exit()
print('Yes')


n = int(input())
l = []
for i in range(n):
	l3 = list(map(int, input().split()))
	l.append(l3)

def f(l, n):
	for i in range(n):
		for j in range(n):
			if l[i][j] != 1:
				lx = []
				for k in range(n):
					l2 = list(map(lambda x: x + l[k][j], l[i]))
					lx.extend(l2)
				if l[i][j] not in lx:
					return 'No'
	return 'Yes'
print(f(l, n))


x = int(input())
t = []
k1 = 0
flag = 0
for i in range(x):
	a = list(map(int, input().split()))
	t.append(a)
if x == 1 and a == [1]:
	print('Yes')
elif x == 1 and a != [1]:
	print('No')
else:
	for i in range(x):
		for j in range(x):
			if t[i][j] == 1:
				continue
			for k in range(x):
				flag2 = 0
				flag = 0
				if t[k][j] == t[i][j]:
					continue
				for l in range(x):
					if l == j:
						continue
					if t[k][j] + t[i][l] == t[i][j]:
						flag = 1
						flag2 = 1
						break
				if flag2 == 1:
					break
			if k == x - 1 and flag == 0:
				k1 = 1
				print('No')
				break
			if k1 == 1:
				break
		if k1 == 1:
			break
	if k1 == 0:
		print('Yes')


n = int(input())
arr = []
for i in range(n):
	li = list(map(int, input().split()))
	arr.append(li)
tc = 0
vc = 0
for i in range(n):
	for j in range(n):
		if arr[i][j] > 1:
			tc += 1
			for k in range(n):
				diff = arr[i][j] - arr[k][j]
				if diff in arr[i]:
					vc += 1
					break
if tc == vc:
	print('Yes')
else:
	print('No')


def transpose(a):
	b = [i[:] for i in a]
	for i in range(len(a)):
		for j in range(len(a[i])):
			b[i][j] = a[j][i]
	return b
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
at = transpose(a)
for i in range(len(a)):
	for j in range(len(a[i])):
		if a[i][j] != 1:
			sum = [k + l for k in a[i] for l in at[j]]
			if a[i][j] not in sum:
				print('NO')
				exit()
print('YES')


import sys
import math
import bisect
import itertools

def solve(A):
	n = len(A)
	for i in range(n):
		for j in range(n):
			if A[i][j] != 1:
				flag = False
				for k in range(n):
					for l in range(n):
						if A[i][k] + A[l][j] == A[i][j]:
							flag = True
				if flag == False:
					return False
	return True

def main():
	n = int(input())
	A = []
	for i in range(n):
		A.append(list(map(int, input().split())))
	if solve(A):
		print('Yes')
	else:
		print('No')
main()


import sys

def do(a, m):
	for x in range(a[0]):
		for y in range(a[0]):
			if m[y][x] != 1:
				for xx in range(a[0]):
					for yy in range(a[0]):
						if xx == x or yy == y:
							continue
						if m[y][x] == m[yy][x] + m[y][xx]:
							break
					else:
						continue
					break
				else:
					print('No')
					return
	print('Yes')

def main():
	a = list(map(int, input().split()))
	m = [list(map(int, input().split())) for i in range(a[0])]
	do(a, m)
main()


def check(grid, i, j, n):
	for ii in range(n):
		for jj in range(n):
			if grid[i][j] == grid[ii][j] + grid[i][jj]:
				return True
	return False
(n, grid, flag) = (int(input()), list(), 0)
for i in range(n):
	grid.extend([list(map(int, input().split()))])
for i in range(n):
	for j in range(n):
		if grid[i][j] != 1:
			if check(grid, i, j, n) is False:
				print('NO')
				exit()
print('YES')


def check(r, c, x):
	rtn = False
	rs = [a[r][i] for i in range(n) if i != c]
	cs = [a[i][c] for i in range(n) if i != r]
	for r in rs:
		for c in cs:
			if r + c == x:
				rtn = True
				break
	return rtn
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
ans = True
for i in range(n):
	for j in range(n):
		if a[i][j] != 1:
			ans &= check(i, j, a[i][j])
print('Yes' if ans else 'No')


n = int(input())
a = []
for i in range(n):
	a.append([int(x) for x in input().split()])
for i in range(n):
	for j in range(n):
		if a[i][j] == 1:
			continue
		val = False
		for k in range(n):
			for l in range(n):
				if a[i][k] + a[l][j] == a[i][j]:
					val = True
		if val == False:
			print('No')
			return
print('Yes')


N = int(input())
table = []
for i in range(N):
	table.append(list(map(int, input().split())))
for i in range(N):
	for j in range(N):
		if table[i][j] == 1:
			continue
		flg = False
		for s in range(N):
			for t in range(N):
				if table[i][j] == table[i][s] + table[t][j]:
					flg = True
					break
		if not flg:
			print('No')
			exit()
print('Yes')


import re
import sys
import math
import string
t = int(input())
l = []
i = 1
while i <= t:
	g = list(map(int, input().strip().split(' ')))
	l.append(g)
	i = i + 1
i = 0
while i < t:
	j = 0
	while j < t:
		a = l[i][j]
		k = 0
		f = 1
		if a != 1:
			while k < t:
				if a - l[k][j] > 0 and a - l[k][j] in l[i]:
					f = 1
					break
				k = k + 1
			else:
				f = 2
				break
		j = j + 1
	if f == 2:
		break
	i = i + 1
if f == 1:
	print('yes')
else:
	print('no')


N = int(input())
matrix = []
for i in range(N):
	matrix.append(list(map(int, input().split())))
for x in range(N):
	for y in range(N):
		if matrix[x][y] != 1:
			for s in range(N):
				for t in range(N):
					if matrix[x][s] + matrix[t][y] == matrix[x][y]:
						break
				else:
					continue
				break
			else:
				print('No')
				break
	else:
		continue
	break
else:
	print('Yes')


n = int(input())
a = list()
for i in range(n):
	a.append([int(x) for x in input().split()])
for j in range(n):
	for i in range(n):
		if a[j][i] == 1:
			continue
		ans = False
		for k in range(n):
			for m in range(n):
				if a[j][k] + a[m][i] == a[j][i]:
					ans = True
		if ans == False:
			print('No')
			exit(0)
print('Yes')


n = int(input())
a = []
for i in range(n):
	a.append(list(map(int, input().split())))
for i in range(n):
	for j in range(n):
		c = 0
		if a[i][j] == 1:
			continue
		for k in range(n):
			for l in range(n):
				if a[i][j] == a[i][k] + a[l][j]:
					c = 1
					break
			if c:
				break
		if not c:
			print('No')
			return
print('Yes')


n = int(input())
l = []
arr = []
for i in range(n):
	l = input().split()
	l = list(map(int, l))
	arr.append(l)

def f(n, arr):
	for i in range(n):
		for j in range(n):
			if arr[i][j] != 1:
				lst = [1 if arr[i][j] == arr[i][s] + arr[t][j] else 0 for s in range(n) if s != j for t in range(n) if t != i]
				if sum(lst) == 0:
					return 'No'
	if i == n - 1 & j == n - 1:
		return 'yes'
print(f(n, arr))


n = int(input())
m = []
for _ in range(n):
	m.append(list(map(int, input().split())))
ans = True
for i in range(n):
	for j in range(n):
		if m[i][j] != 1:
			found = False
			for x in range(n):
				for y in range(n):
					if x != i and y != j and (m[i][y] + m[x][j] == m[i][j]):
						found = True
			if not found:
				ans = False
if ans:
	print('Yes')
else:
	print('No')


f = lambda : map(int, input().split())
m = [list(f()) for _ in range(int(input()))]
(t, r) = (list(map(set, zip(*m))), True)
for row in m:
	r &= all((x < 2 or any((x - a in c for a in row)) for (x, c) in zip(row, t)))
print('YNEOS'[not r::2])


dim = int(input())
matrix = []
val = []
for i in range(dim):
	matrix.append([])
	val.append([])
for i in range(dim):
	matrix[i] = [int(g) for g in input().split()]
	val[i] = [False] * dim
for i in range(len(matrix)):
	for j in range(len(matrix)):
		ele = matrix[i][j]
		if ele == 1:
			val[i][j] = True
			continue
		else:
			count = 0
			for x in range(len(matrix)):
				for y in range(len(matrix)):
					if [i, j] != [x, y]:
						if matrix[i][y] + matrix[x][j] == matrix[i][j]:
							val[i][j] = True
for i in range(len(val)):
	for j in range(len(val)):
		if val[i][j] == False:
			print('No')
			exit()
print('Yes')


n = int(input())
fl = [list(map(int, input().split())) for i in range(n)]
ok = True
for i in range(n):
	for j in range(n):
		if fl[i][j] != 1:
			sok = False
			k = m = 0
			while not sok and k < n:
				m = 0
				while not sok and m < n:
					sok = j != m and i != k and (fl[i][j] == fl[k][j] + fl[i][m])
					m += 1
				k += 1
			ok = sok * ok
if ok:
	print('Yes')
else:
	print('No')


n = int(input())
aij = [list(map(int, input().split())) for i in range(n)]
ans = 'YES'
for i in range(n):
	for j in range(n):
		if aij[i][j] != 1:
			flag = 0
			for i2 in range(n):
				for j2 in range(n):
					if i2 != i and j2 != j and (aij[i2][j] + aij[i][j2] == aij[i][j]):
						flag = 1
			if flag == 0:
				ans = 'NO'
print(ans)


n = int(input())
i = 0
grid = []
while i < n:
	grid += [list(map(int, input().split(' ')))]
	i += 1
broke = False
for j in range(len(grid)):
	for i in range(len(grid[j])):
		if grid[j][i] != 1:
			found = False
			for k in range(len(grid[0])):
				curr = grid[j][k]
				for y in range(len(grid)):
					curr1 = grid[y][i]
					if curr + curr1 == grid[j][i]:
						found = True
			if not found:
				broke = True
				break
		if broke:
			break
	if broke:
		break
if not broke:
	print('YES')
else:
	print('NO')


n = int(input())
a = [0] * 50
for i in range(n):
	a[i] = list(map(int, input().split()))
for i in range(n):
	for j in range(n):
		if a[i][j] != 1:
			fl = 0
			for k in range(n):
				for t in range(n):
					if a[i][j] == a[i][k] + a[t][j]:
						fl = 1
			if fl == 0:
				print('No')
				quit()
print('Yes')


n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
for i in range(n):
	for j in range(n):
		if a[i][j] != 1:
			f = 0
			no = a[i][j]
			for k in range(n):
				for l in range(n):
					if no == a[i][k] + a[l][j]:
						f = 1
			if f == 0:
				print('No')
				quit()
print('Yes')


n = int(input())
lab = []
for i in range(n):
	line = list(map(int, input().split()))
	lab.append([])
	for j in range(n):
		lab[i].append(line[j])
flag = True
for i in range(n):
	for j in range(n):
		x = lab[i][j]
		if x != 1:
			local_flag = False
			for a in [lab[i][y] for y in range(n)]:
				for b in [lab[y][j] for y in range(n)]:
					if x == a + b:
						local_flag = True
			if not local_flag:
				flag = False
print('Yes') if flag else print('No')


def is_sum(i, j):
	v = l[i][j]
	for k in range(i):
		if l[k][j] < v:
			if v - l[k][j] in l[i]:
				return True
	for k in range(i + 1, n):
		if l[k][j] < v:
			if v - l[k][j] in l[i]:
				return True
	return False

def f(l):
	for i in range(n):
		for j in range(n):
			if l[i][j] != 1:
				if not is_sum(i, j):
					return False
	return True
n = int(input())
l = []
for _ in range(n):
	l.append(list(map(int, input().split())))
if f(l):
	print('Yes')
else:
	print('No')


dim = int(input())
a = []
for i in range(0, dim):
	a.append(input().split())
c = 0

def check(x, y):
	if int(a[x][y]) == 1:
		return 1
	else:
		h = 0
		for i in range(0, dim):
			for j in range(0, dim):
				if int(a[x][j]) + int(a[i][y]) == int(a[x][y]):
					return 1
for n in range(0, dim):
	for m in range(0, dim):
		g = check(n, m)
		if g == None:
			g = 0
		c = c + g
if c == dim * dim:
	print('Yes')
else:
	print('No')


sets = []
n = int(input())
Arr = [[0 for j in range(n)] for i in range(n)]
for i in range(n):
	s = input().split()
	c = set()
	for j in range(n):
		a = int(s[j])
		Arr[i][j] = a
		c.add(a)
	sets.append(c)

def check_arr():
	for i in range(n):
		for j in range(n):
			if Arr[i][j] == 1:
				continue
			if not check_row(i, j):
				return False
	return True

def check_row(i, j):
	a = Arr[i][j]
	for k in range(n):
		if k == i:
			continue
		if a - Arr[k][j] in sets[i]:
			return True
	return False
if check_arr():
	print('Yes')
else:
	print('No')


import sys

def main():
	n = int(sys.stdin.readline())
	mat = [None for __ in range(n)]
	for indx in range(n):
		mat[indx] = list(map(int, sys.stdin.readline().split()))
	good = True
	for row in range(n):
		for col in range(n):
			if mat[row][col] == 1:
				continue
			else:
				good &= check_this_element(mat, row, col)
	if good:
		print('Yes')
	else:
		print('No')

def check_this_element(mat, row, col):
	n = len(mat)
	for _row in range(n):
		for _col in range(n):
			if mat[_row][col] + mat[row][_col] == mat[row][col]:
				return True
	return False
main()


n = int(input())
l = []
for _ in range(n):
	l.append(list(map(int, input().split())))
x = 1
for i in range(n):
	if x == -1:
		break
	for j in range(n):
		if x == -1:
			break
		if l[i][j] != 1:
			c = 0
			for k in range(n):
				for m in range(n):
					if l[k][j] + l[i][m] == l[i][j]:
						c = 1
						break
						break
			if c == 0:
				x = -1
if x == -1:
	print('No')
else:
	print('Yes')


n = int(input())
a = [[0] * n for i in range(n)]
f = True
d = True
for i in range(n):
	a[i] = list(map(int, input().split(' ')))
for i in range(n):
	for j in range(n):
		s = a[i][j]
		if s != 1:
			f = False
			for t in range(n):
				if t != i:
					x = s - a[t][j]
					if x in a[i]:
						f = True
		if f == False:
			d = False
if not d:
	print('No')
else:
	print('Yes')


n = int(input())
a = []
for i in range(n):
	a += [list(map(int, input().split()))]
for i in range(n):
	for j in range(n):
		flag = False
		if a[i][j] == 1:
			flag = True
			continue
		for k in range(n):
			if k != i:
				for l in range(n):
					if l != j:
						if a[k][j] + a[i][l] == a[i][j]:
							flag = True
							break
			if flag:
				break
		if not flag:
			break
	if not flag:
		break
if not flag:
	print('No')
else:
	print('Yes')


def check(i, j):
	cur = tbl[i][j]
	if cur == 1:
		return 1
	good = 0
	for k in range(n):
		if tbl[k][j] >= cur:
			continue
		for l in range(n):
			tk = tbl[k][j] + tbl[i][l]
			if tk == cur:
				good = 1
				break
	return good
n = int(input())
tbl = []
for i in range(n):
	tbl.append([int(i) for i in input().split()])
br = 0
for i in range(n):
	for j in range(n):
		isgood = check(i, j)
		if not isgood:
			br = 1
			break
	if br:
		break
if br:
	print('No')
else:
	print('Yes')


from sys import stdin, stdout

def rint():
	return map(int, stdin.readline().split())

def check(i, j):
	for r in range(n):
		for c in range(n):
			if a[i][c] + a[r][j] == a[i][j]:
				return 1
	return 0
n = int(input())
a = [[] for _ in range(n)]
for i in range(n):
	a[i] = list(rint())
for i in range(n):
	for j in range(n):
		if a[i][j] == 1:
			continue
		if check(i, j) == 0:
			print('No')
			exit()
print('Yes')


n = input()
n = int(n)
a = []
for i in range(n):
	x = input().split()
	x = [int(p) for p in x]
	a.append(x)
can = True
for i in range(n):
	for j in range(n):
		if a[i][j] != 1:
			p = False
			for ii in range(n):
				for jj in range(n):
					if a[i][jj] + a[ii][j] == a[i][j]:
						p = True
			if p == False:
				can = False
if can:
	print('Yes')
else:
	print('No')


def solve(g):
	for i in range(n):
		for j in range(n):
			if g[i][j] == 1:
				continue
			for p in range(n):
				for q in range(n):
					if p == i or q == j:
						continue
					if g[i][q] + g[p][j] == g[i][j]:
						break
				else:
					continue
				break
			else:
				return 'No'
	return 'Yes'
n = int(input())
g = []
for i in range(n):
	g.append([int(item) for item in input().split()])
print(solve(g))


n = int(input())
flag = False
A = [0] * n
for i in range(n):
	A[i] = list(map(int, input().split()))
for i in range(n):
	for j in range(n):
		if A[i][j] == 1:
			continue
		for x in range(n):
			for y in range(n):
				if A[i][y] + A[x][j] == A[i][j]:
					flag = True
					break
			if flag:
				break
		if not flag:
			print('No')
			exit(0)
		flag = False
print('Yes')
exit(0)


n = int(input())
d = []
for i in range(n):
	d.append(list(map(int, input().split())))
fl = True
for i in range(n):
	for j in range(n):
		e = d[i][j]
		if e != 1:
			a = set()
			f = False
			for i1 in range(n):
				if i != i1:
					a.add(d[i1][j])
			for j1 in range(n):
				if j != j1:
					if e - d[i][j1] in a:
						f = True
		else:
			f = True
		fl = f and fl
if fl:
	print('Yes')
else:
	print('No')


n = int(input())
a = []
for i in range(n):
	a.append(list(map(int, input().split())))
for x in range(n):
	for y in range(n):
		if a[x][y] == 1:
			continue
		ans = 'No'
		for s in range(n):
			for t in range(n):
				if a[x][y] == a[x][s] + a[t][y]:
					ans = 'Yes'
					break
			if ans == 'Yes':
				break
		if ans == 'No':
			print(ans)
			exit(0)
print('Yes')


n = int(input())
table = [[0] * n] * n
for i in range(n):
	table[i] = [int(i) for i in input().split()]
for row in range(n):
	for column in range(n):
		if table[row][column] != 1:
			found = False
			for r in range(n):
				for c in range(n):
					if table[r][column] + table[row][c] == table[row][column]:
						found = True
						break
				if found:
					break
			if not found:
				print('No')
				exit()
print('Yes')


n = int(input())
grid = [[int(c) for c in input().split()] for _ in range(n)]

def has_sum(lst, target):
	memo = set()
	for e in lst:
		if e in memo:
			return True
		else:
			memo.add(target - e)
	return False
for r in range(n):
	for c in range(n):
		curr = grid[r][c]
		if curr != 1:
			row = [grid[r][cc] for cc in range(n) if cc != c]
			col = [grid[rr][c] for rr in range(n) if rr != r]
			found = False
			for rr in row:
				if not found:
					for cc in col:
						if rr + cc == curr:
							found = True
							break
				else:
					break
			if not found:
				print('No')
				exit()
print('Yes')


n = int(input())
x = []
for i in range(n):
	x.append(list(map(int, input().split())))
y = list(map(list, zip(*x)))
for i in range(n):
	for j in range(n):
		t = False
		num = x[i][j]
		if num != 1:
			row = x[i]
			col = y[j]
			for l in row:
				for k in col:
					if l + k == num:
						t = True
			if t == False:
				print('No')
				exit()
print('Yes')


a = [list(map(int, input().split())) for i in range(int(input()))]
n = len(a)
for i in range(n):
	for j in range(n):
		if a[i][j] != 1:
			found = False
			for i2 in range(n):
				for j2 in range(n):
					if a[i][j] == a[i][j2] + a[i2][j]:
						found = True
			if not found:
				print('No\n')
				exit()
print('Yes')


n = int(input())
grid = [[int(x) for x in input().split()] for _ in range(n)]

def check(x, y):
	row = set(grid[x][:y] + grid[x][y + 1:])
	for i in range(n):
		if i == x:
			continue
		if grid[x][y] - grid[i][y] in row:
			return True
	return False
for i in range(n):
	for j in range(n):
		if grid[i][j] != 1 and (not check(i, j)):
			print('NO')
			exit()
print('YES')


def int_input():
	return map(int, input().split())
n = int(input())
matr = [list(int_input()) for i in range(n)]
good = True
for row in range(n):
	nums = set(matr[row])
	for col in range(n):
		num = matr[row][col]
		if num == 1:
			continue
		cur_good = False
		for i in range(n):
			cur_good |= num - matr[i][col] in nums
		good &= cur_good
print('Yes' if good else 'No')


n = int(input())
s = []
for k in range(n):
	s.append([int(i) for i in input().split()])
t = 0
for i in range(n):
	for j in range(n):
		l = 0
		if s[i][j] != 1:
			for x in range(n):
				for y in range(n):
					if s[i][x] + s[y][j] == s[i][j]:
						l = 1
			if not l:
				t = 1
if t:
	print('No')
else:
	print('Yes')


def is_good_lab():
	for x in range(num):
		for i in range(num):
			if lab[x][i] != 1:
				sum_found = False
				for j in range(num):
					sum_found = False
					if str(lab[x][i] - lab[j][i]) in mapa[x]:
						sum_found = True
						break
				if not sum_found:
					return False
	return True
num = int(input())
lab = [[0 for x in range(num)] for y in range(num)]
t = 0
mapa = {}
for i in range(num):
	row = input()
	row = row.split(' ')
	mapa[i] = {}
	for (n, value) in enumerate(row):
		lab[i][n] = int(value)
		mapa[i][value] = ''
print('Yes' if is_good_lab() else 'No')


n = int(input())
a = [[int(j) for j in input().split(' ')] for i in range(n)]

def check(a, n):
	for i in range(len(a)):
		for j in range(len(a)):
			v = a[i][j]
			if v == 1:
				continue
			s = [a[i][x] + a[y][j] for x in range(n) for y in range(n)]
			if v not in s:
				return False
	return True
print('Yes' if check(a, n) else 'No')


n = int(input())
rows = cols = n
lab_mat = [[0 for i in range(cols)] for j in range(rows)]
for i in range(rows):
	row_input = input().split()
	for j in range(cols):
		lab_mat[i][j] = int(row_input[j])

def column(matrix, i):
	return [row[i] for row in matrix]
good_flag = [[False for i in range(cols)] for j in range(rows)]
for i in range(rows):
	for j in range(cols):
		element = lab_mat[i][j]
		if element == 1:
			good_flag[i][j] = True
			continue
		else:
			for x in lab_mat[i]:
				for y in column(lab_mat, j):
					if element == x + y:
						good_flag[i][j] = True
						break
			if not good_flag:
				good_flag[i][j] = False
				break
flag_sum = 0
for i in range(rows):
	for j in range(cols):
		flag_sum += good_flag[i][j]
if flag_sum == n ** 2:
	print('YES')
else:
	print('NO')


n = int(input())
a = [[int(x) for x in input().split()] for y in range(n)]
ans = True
for i in range(n):
	for j in range(n):
		if a[i][j] == 1:
			continue
		ans = False
		for k in range(i):
			for l in range(j):
				if a[k][j] + a[i][l] == a[i][j]:
					ans = True
		for k in range(i + 1, n):
			for l in range(j):
				if a[k][j] + a[i][l] == a[i][j]:
					ans = True
		for k in range(i):
			for l in range(j + 1, n):
				if a[k][j] + a[i][l] == a[i][j]:
					ans = True
		for k in range(i + 1, n):
			for l in range(j + 1, n):
				if a[k][j] + a[i][l] == a[i][j]:
					ans = True
		if not ans:
			break
	if not ans:
		break
if ans:
	print('Yes')
else:
	print('No')


import sys

def is_good(lab):
	n = len(lab)
	for i in range(n):
		for j in range(n):
			v = lab[i][j]
			if v > 1 and all((x + y != v for x in lab[i] for y in (lab[k][j] for k in range(n)))):
				return False
	return True
n = int(input())
lab = [[int(i) for i in input().split()] for _ in range(n)]
print('Yes' if is_good(lab) else 'No')


n = int(input())
arr = [list(map(int, input().split())) for _ in range(n)]

def good_num(i, j):
	for r in range(n):
		if r != j:
			for c in range(n):
				if c != i:
					if arr[i][j] == arr[i][r] + arr[c][j]:
						return True
	return False
flag = False
for i in range(n):
	for j in range(n):
		if arr[i][j] == 1:
			continue
		if not good_num(i, j):
			flag = True
			print('No')
			break
	if flag:
		break
if not flag:
	print('Yes')


a = int(input())
b = []
for i in range(a):
	b.append([int(x) for x in input().split()])
for i in range(a):
	for j in range(a):
		if b[i][j] == 1:
			continue
		y = 1
		for h in range(a):
			for g in range(a):
				if b[i][h] + b[g][j] == b[i][j]:
					y = 2
		if y == 1:
			print('NO')
			exit()
print('YES')


n = int(input())
a = [[0 for col in range(n)] for row in range(n)]
for i in range(n):
	a[i] = list(map(int, input().split()))
b = list(zip(*a))
for i in range(n):
	for j in range(n):
		if a[i][j] != 1:
			if not any((a[i][j] - x in b[j] for x in a[i])):
				print('No')
				quit()
print('Yes')


def main_function():
	intermediate_list = [[int(i) for i in input().split(' ')] for j in range(int(input()))]
	for i in range(len(intermediate_list)):
		for j in range(len(intermediate_list)):
			if not intermediate_list[i][j] == 1:
				is_inner_most_loop_broken = False
				is_second_loop_broken = False
				for h in range(len(intermediate_list)):
					if h != i:
						for y in range(len(intermediate_list)):
							if y != j:
								if intermediate_list[i][j] == intermediate_list[i][y] + intermediate_list[h][j]:
									is_inner_most_loop_broken = True
									break
						if is_inner_most_loop_broken:
							is_second_loop_broken = True
							break
				if not is_second_loop_broken:
					return 'No'
	return 'Yes'
print(main_function())


n = int(input().strip())
a = [[int(num) for num in input().strip().split()] for _ in range(n)]
ans = 'Yes'
for i in range(n):
	for j in range(n):
		if a[i][j] == 1:
			continue
		found = False
		for k in range(n):
			for l in range(n):
				if a[i][l] + a[k][j] == a[i][j]:
					found = True
					break
			if found:
				break
		if not found:
			ans = 'No'
			break
	if ans == 'No':
		break
print(ans)


n = int(input().strip())
matrix = []
for _ in range(n):
	matrix.append(list(map(int, input().strip().split())))

def check(matrix, n):
	for i in range(n):
		for j in range(n):
			if matrix[i][j] != 1:
				found = 0
				for p in range(0, n):
					difference = matrix[i][j] - matrix[i][p]
					if found == 1:
						break
					for q in range(n):
						if difference == matrix[q][j]:
							found = 1
							break
				if found == 0:
					return 'NO'
	return 'Yes'
print(check(matrix, n))


n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
(c, g) = (0, 0)
for i in range(n):
	for j in range(n):
		if a[i][j] != 1:
			c += 1
			f = 0
			for h in range(n):
				for k in range(n):
					if a[i][j] == a[i][h] + a[k][j]:
						g += 1
						f = 1
						break
				if f == 1:
					break
print(['No', 'Yes'][g == c])


import sys

def find(l, c, v):
	for li in range(n):
		for co in range(n):
			if not (co == c and li == l):
				if labo[li][c] + labo[l][co] == v:
					return True
	return False
n = int(sys.stdin.readline())
labo = [list(map(int, sys.stdin.readline().split())) for loop in range(n)]
continuer = True
for l in range(n):
	if continuer:
		for c in range(n):
			if continuer:
				if labo[l][c] != 1:
					if not find(l, c, labo[l][c]):
						continuer = False
if continuer:
	print('Yes')
else:
	print('No')


n = int(input())
data = [list(map(int, input().split())) for _ in range(n)]
data_t = [[0] * n for _ in range(n)]
for i in range(n):
	for j in range(n):
		data_t[j][i] = data[i][j]

def sums(row1, row2):
	result = []
	for v1 in row1:
		for v2 in row2:
			result.append(v1 + v2)
	return result
fail = False
for i in range(n):
	for j in range(n):
		if data[i][j] == 1:
			continue
		if data[i][j] not in sums(data[i], data_t[j]):
			fail = True
			break
	if fail:
		break
print(('Yes', 'No')[fail])


n = int(input())
a = []
b = []
s = 0
for i in range(n):
	b.append([0] * n)
for i in range(n):
	a.append(list(map(int, input().split())))
for i in range(n):
	for j in range(n):
		for h in range(n):
			for w in range(n):
				if a[h][j] + a[i][w] == a[i][j] or a[i][j] == 1:
					b[i][j] = 1
					break
			if w != n - 1:
				break
	if b[i][j] == 0:
		break
for i in range(n):
	for j in range(n):
		s = s + b[i][j]
if s == n ** 2:
	print('Yes')
else:
	print('No')


import sys

def read():
	return sys.stdin.readline().strip()

def write(a):
	sys.stdout.write(a)

def check(a, n, i, j):
	s = a[i][j]
	x = []
	y = []
	for ix in range(n):
		if ix != i:
			y += [a[ix][j]]
	for jx in range(n):
		if jx != j:
			x += [a[i][jx]]
	for i in x:
		for j in y:
			if i + j == s:
				return True
	return False

def solve(a, n):
	for i in range(n):
		for j in range(n):
			if a[i][j] != 1:
				if not check(a, n, i, j):
					return 'No'
	return 'Yes'

def main():
	n = int(input())
	a = [[int(j) for j in read().split()] for i in range(n)]
	print(solve(a, n))
main()


n = int(input())
a = list()
for i in range(n):
	row = [int(j) for j in input().split()]
	a.append(row)
b = [set(a[i]) for i in range(n)]
if all((all((a[i][j] == 1 or any((a[i][j] - a[k][j] in b[i] for k in range(n))) for j in range(n))) for i in range(n))):
	print('Yes')
else:
	print('No')


n = int(input())
data = []
for i in range(n):
	data += [list(map(int, input().split()))]
for i in range(n):
	for j in range(n):
		if data[i][j] == 1:
			t = True
			continue
		t = False
		for k in range(n):
			for m in range(n):
				if data[i][k] + data[m][j] == data[i][j]:
					t = True
					break
		if not t:
			print('No')
			break
	if not t:
		break
if t:
	print('Yes')


def cal(a, i, j, n):
	for k in range(n):
		for kk in range(n):
			if a[i][j] == a[i][k] + a[kk][j]:
				return True
	return False
n = int(input())
a = []
for i in range(n):
	a.append([*map(int, input().split())])
for i in range(n):
	for j in range(n):
		if a[i][j] != 1:
			if cal(a, i, j, n) == False:
				print('No')
				exit()
print('Yes')


def func(arr):
	for i in range(n):
		for j in range(n):
			if arr[i][j] != 1:
				check = 0
				for k in range(n):
					if arr[i][j] - arr[k][j] in arr[i]:
						check = 1
						break
				if check == 0:
					return False
	return True
n = int(input())
arr = []
for i in range(n):
	arr.append(list(map(int, input().split())))
if func(arr):
	print('yes')
else:
	print('no')


def solve():
	n = get(int)
	lab = [get([int]) for i in range(n)]
	labT = list(zip(*lab))
	for (r, row) in enumerate(lab):
		for (c, elem) in enumerate(row):
			if elem == 1:
				continue
			col = labT[c]
			good = False
			for a in row[:c] + row[c + 1:]:
				for b in col[:r] + col[r + 1:]:
					if a + b == elem:
						good = True
						break
			if not good:
				return 'NO'
	return 'YES'
_testcases = '\n3\n1 1 2\n2 3 1\n6 4 1\n\nYES\n\n3\n1 5 2\n1 1 1\n1 2 3\n\nNO\n\n'.strip()
import re
import sys
import math
import heapq
from heapq import heapify, heappop, heappush
import bisect
import string
from bisect import bisect_left, bisect_right
import operator
from operator import itemgetter, attrgetter
import itertools
import collections
inf = float('inf')
sys.setrecursionlimit(10000)

def tree():
	return collections.defaultdict(tree)

def cache(func):
	cache_dict = {}

	def _cached_func(*args, _get_cache=False):
		if _get_cache:
			return cache_dict
		if args in cache_dict:
			return cache_dict[args]
		cache_dict[args] = func(*args)
		return cache_dict[args]
	return _cached_func

def equal(x, y, epsilon=1e-06):
	if -epsilon <= x - y <= epsilon:
		return True
	if -epsilon <= x <= epsilon or -epsilon <= y <= epsilon:
		return False
	return -epsilon <= (x - y) / x <= epsilon or -epsilon <= (x - y) / y <= epsilon

def get(_type):
	if type(_type) == list:
		if len(_type) == 1:
			_type = _type[0]
			return list(map(_type, input().strip().split()))
		else:
			return [_type[i](inp) for (i, inp) in enumerate(input().strip().split())]
	else:
		return _type(input().strip())
(_p, print) = (print, lambda *a, **b: None)
_p(solve())


n = int(input())
l = [list(map(int, input().split())) for _ in range(n)]
flag = 0
for i in range(n):
	for j in range(n):
		if l[i][j] == 1 or any((l[i][j] - l[x][j] in l[i] for x in range(n))):
			continue
		else:
			print('No')
			flag = 1
			break
	if flag == 1:
		break
else:
	print('Yes')


def test(a):
	for i in range(len(a)):
		for j in range(len(a[i])):
			if a[i][j] == 1:
				continue
			flag = 0
			for k in range(len(a[i])):
				if a[i][j] - a[k][j] in a[i]:
					flag = 1
					break
			if flag == 0:
				return 'No'
	return 'Yes'
n = int(input())
a = list()
for _ in range(n):
	a.append(list(map(int, input().split())))
print(test(a))


from sys import stdin, stdout

def main():
	n = int(stdin.readline())
	mat = []
	for i in range(n):
		mat.append(list(map(int, stdin.readline().split())))
	for i in range(n):
		for j in range(n):
			st = True
			for u in range(n):
				for k in range(n):
					if mat[i][j] == 1 or mat[i][j] == mat[u][j] + mat[i][k]:
						st = False
						break
				if not st:
					break
			if st:
				return False
	return True
print('Yes' if main() else 'No')


n = int(input())
L = [[int(x) for x in input().split()] for _ in range(0, n)]
valid = True
for i in range(n):
	for j in range(n):
		if L[i][j] != 1:
			found = False
			for a in range(n):
				for b in range(n):
					if L[i][b] + L[a][j] == L[i][j]:
						found = True
			if not found:
				valid = False
if valid:
	print('YES')
else:
	print('NO')


n = int(input())
m = [list(map(int, input().split())) for i in range(n)]
fl = 1
for i in range(n):
	for j in range(n):
		if m[i][j] == 1:
			continue
		cur = []
		for x in range(n):
			for y in range(n):
				if j == x or y == i:
					continue
				cur.append(m[i][x] + m[y][j])
		if m[i][j] not in cur:
			fl = 0
if fl:
	print('Yes')
else:
	print('No')


n = int(input())
a = []
for i in range(n):
	a.append([int(j) for j in input().split()])
flag = 'Yes'
for i in range(n):
	for j in range(n):
		if a[i][j] != 1:
			f = False
			for k in range(n):
				if f:
					break
				for z in range(n):
					if a[k][j] + a[i][z] == a[i][j]:
						f = True
					if f:
						break
			if not f:
				flag = 'No'
print(flag)


n = int(input())
a = []
for i in range(n):
	a.append(list(map(int, input().split())))
ans = 0
for i in range(n):
	for j in range(n):
		flag = False
		if a[i][j] != 1:
			for k in range(n):
				for l in range(n):
					if a[i][j] == a[k][j] + a[i][l]:
						ans += 1
						flag = True
						break
				if flag:
					break
		else:
			ans += 1
print('Yes') if ans == n ** 2 else print('No')


from sys import stdin, stdout
n = int(stdin.readline())
values = []
for i in range(n):
	values.append(list(map(int, stdin.readline().split())))
label = 1
for i in range(n):
	for j in range(n):
		s = set()
		if values[i][j] == 1:
			continue
		for z in range(n):
			s.add(values[i][z])
		for z in range(n):
			if values[i][j] - values[z][j] in s:
				break
		else:
			label = 0
if label:
	stdout.write('Yes')
else:
	stdout.write('No')


import sys
n = int(input())
a = [0] * n
for i in range(n):
	a[i] = list(map(int, input().split()))
for x in range(n):
	for y in range(n):
		if a[x][y] != 1:
			for t in range(n):
				if a[x][y] - a[t][y] in a[x]:
					break
			else:
				print('No')
				sys.exit()
print('Yes')


def solve(a, n):
	for i in range(n):
		for j in range(n):
			v = a[i][j]
			if v == 1:
				continue
			s = [a[i][x] + a[y][j] for x in range(n) for y in range(n)]
			if v not in s:
				return False
	return True
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
print('Yes' if solve(a, n) else 'No')


m = []
for i in range(int(input())):
	m.append(list(map(int, input().split())))

def solve():
	for row in range(len(m)):
		for column in range(len(m)):
			if m[row][column] == 1:
				continue
			r = set(m[row])
			r.remove(m[row][column])
			c = set()
			for i in range(len(m)):
				c.add(m[i][column])
			c.remove(m[row][column])
			found = False
			for item in r:
				if m[row][column] - item in c:
					found = True
					break
			if not found:
				return 'No'
	return 'Yes'
print(solve())


n = int(input())
a = [[int(i) for i in input().split()] for _ in range(n)]
b = [set(a[i]) for i in range(n)]
if all((all((a[i][j] == 1 or any((a[i][j] - a[k][j] in b[i] for k in range(n))) for j in range(n))) for i in range(n))):
	print('Yes')
else:
	print('No')


import math as mt
import sys, string
input = sys.stdin.readline
import random
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())

def check(s, d, l):
	de = defaultdict(int)
	xe = defaultdict(int)
	key = l[s][d]
	for i in range(n):
		if i != d:
			de[l[s][i]] += 1
	for i in range(n):
		if i != s:
			xe[l[i][d]] += 1
	for i in range(n):
		if i != d:
			if xe[key - l[s][i]]:
				return True
	for i in range(n):
		if i != s:
			if de[key - l[i][d]]:
				return True
	de.clear()
	xe.clear()
	return False
row = defaultdict(int)
col = defaultdict(int)
n = I()
l = []
for i in range(n):
	x = L()
	l.append(x)
for i in range(n):
	for j in range(n):
		if l[i][j] != 1:
			if check(i, j, l):
				continue
			else:
				print('No')
				exit()
print('Yes')


a = int(input())
c = str('Yes')
n = int(0)
mass = [0 for i in range(a)]
for i in range(a):
	mass[i] = str(input()).split(' ')
for x in range(a):
	for y in range(a):
		mass[x][y] = int(mass[x][y])
for x in range(a):
	for y in range(a):
		if int(mass[x][y]) != 1:
			n = 0
			for xx in range(a):
				for yy in range(a):
					if mass[xx][y] + mass[x][yy] == mass[x][y]:
						n = 1
			if n == 0:
				c = 'No'
print(c)


def findSum(n, r, c, lim, grid):
	for i in range(lim):
		for j in range(lim):
			if grid[r][i] + grid[j][c] == n:
				return True
	return False

def main():
	n = int(input())
	grid = []
	for i in range(n):
		grid.append([int(n) for n in input().split()])
	for r in range(n):
		for c in range(n):
			if grid[r][c] == 1:
				continue
			if not findSum(grid[r][c], r, c, n, grid):
				print('No')
				return
	print('Yes')
main()


def good(lab):
	for (i, line) in enumerate(lab):
		for (j, item) in enumerate(line):
			if item == 1:
				continue
			flag = False
			for (k, x) in enumerate(line):
				if j == k:
					continue
				col = [l[j] for l in lab]
				for (m, y) in enumerate(col):
					if m == i:
						continue
					if x + y == item:
						flag = True
			if not flag:
				return 'No'
	return 'Yes'

def main():
	N = int(input())
	lab = [[int(item) for item in input().split()] for _ in range(N)]
	print(good(lab))
main()


n = int(input())
grid = [list(map(int, input().split())) for _ in range(n)]
for x in range(n):
	for y in range(n):
		element = grid[x][y]
		if element == 1:
			continue
		found = False
		for s in range(n):
			if s == y:
				continue
			for t in range(n):
				if t == x:
					continue
				check = grid[x][s] + grid[t][y]
				if check == element:
					found = True
		if not found:
			print('No')
			exit()
print('Yes')


def isClean(n, grid, rows, cols):
	for i in range(n):
		for j in range(n):
			idx = i * n + j
			if grid[idx] != 1:
				isValid = False
				for row_v in rows[i]:
					if grid[idx] - row_v in cols[j]:
						isValid = True
						break
				if not isValid:
					print('No')
					return
	print('Yes')
n = int(input().strip())
grid = []
for i in range(n):
	row = list(map(int, input().strip().split(' ')))
	grid.extend(row)
rows = [set() for _ in range(n)]
cols = [set() for _ in range(n)]
for i in range(n):
	for j in range(n):
		idx = i * n + j
		rows[i].add(grid[idx])
		cols[j].add(grid[idx])
isClean(n, grid, rows, cols)


import sys
n = 0
num = [[] * 2]

def check(i, j):
	num = a[i][j]
	for x in range(0, n):
		if x == i:
			continue
		for y in range(0, n):
			if y == j:
				continue
			if a[x][j] + a[i][y] == num:
				return False
	return True
n = int(input().strip())
a = [[] * 50] * 50
mark = 0
for i in range(n):
	a[i] = list(map(int, input().strip().split()))
for i in range(n):
	for j in range(n):
		if a[i][j] == 1:
			continue
		if check(i, j):
			mark = 1
		if mark == 1:
			break
	if mark == 1:
		break
if mark == 1:
	print('No')
else:
	print('Yes')


n = int(input())
a = []
for i in range(n):
	a.append([int(j) for j in input().split()])

def isThere(mas, i, j, n):
	for ii in range(n):
		for jj in range(n):
			if mas[ii][j] + mas[i][jj] == mas[i][j]:
				return True
	return False
res = 'Yes'
for i in range(n):
	for j in range(n):
		if not a[i][j] == 1:
			if not isThere(a, i, j, n):
				res = 'No'
print(res)


n = int(input())
lab = []

def is_valid_cell(i, j):
	row = lab[i]
	column = [lab[i][j] - lab[x][j] for x in range(n)]
	for each in column:
		if each in row:
			return True
	return False
for i in range(n):
	line = [int(x) for x in input().split(' ')]
	lab.append(line)
result = 'YES'
for i in range(n):
	for j in range(n):
		if lab[i][j] != 1:
			if not is_valid_cell(i, j):
				result = 'NO'
				break
	else:
		continue
	break
print(result)


n = int(input())
a = []
for i in range(n):
	a.append(list(map(int, input().split())))
ans = 0
for i in range(n):
	for j in range(n):
		if a[i][j] == 1:
			ans = ans + 1
			continue
		ans += 1 + min((abs(a[i][j] - a[i][k] - a[t][j]) for k in range(0, n) for t in range(0, n)))
if ans == n * n:
	print('Yes')
else:
	print('No')


def r():
	return list(map(int, input().split()))
n = int(input())
matr = [r() for i in range(n)]
ans = True
columns = list(map(set, zip(*matr)))
for row in matr:
	ans &= all((x == 1 or any((x - a in row for a in col)) for (x, col) in zip(row, columns)))
print('Yes' if ans else 'No')


n = int(input())
T = [[] for i in range(n)]
for i in range(n):
	a = list(map(int, input().split()))
	T[i] = a
flag = True
for i in range(n):
	for j in range(n):
		if T[i][j] != 1:
			flag1 = False
			for k in range(n):
				for l in range(n):
					if k != i and l != j and (T[i][j] == T[k][j] + T[i][l]):
						flag1 = True
			if not flag1:
				flag = False
if flag:
	print('Yes')
else:
	print('No')


n = int(input())
a = [[[] for i in range(n)] for i in range(n)]
k = 0
for i in range(n):
	a[i] = map(int, input().split())
	a[i] = list(a[i])
	for j in range(n):
		if a[i][j] == 1:
			k += 1
fg = 0
if k == n * n:
	print('Yes')
else:
	for i in range(n):
		for j in range(n):
			if a[i][j] != 1:
				zz = 0
				for ii in range(n):
					if ii == i:
						continue
					for jj in range(n):
						if jj == j:
							continue
						if a[ii][j] + a[i][jj] == a[i][j]:
							zz = 1
				if zz == 0:
					fg = 1
					break
	if fg == 1:
		print('No')
	else:
		print('Yes')


n = int(input())
lab = [list(map(int, input().split())) for _ in range(n)]

def check(i, j):
	val = lab[i][j]
	for p in range(n):
		row = lab[i][p]
		for q in range(n):
			if val == row + lab[q][j]:
				return True
	return False
flag = True
for i in range(n):
	for j in range(n):
		if lab[i][j] != 1:
			if not check(i, j):
				flag = False
				break
print('Yes') if flag else print('No')


def fin(s, row, column):
	for i in row:
		for j in column:
			if i + j == s:
				return True
	return False
n = int(input())
a = []
for i in range(n):
	k = input().split(' ')
	k = list(map(int, k))
	a.append(k)
ans = True
for i in range(n):
	for j in range(n):
		if a[i][j] == 1:
			continue
		else:
			s = a[i][j]
			row = a[i]
			column = []
			for t in range(n):
				column.append(a[t][j])
			ans = fin(s, row, column)
			if ans == False:
				break
	if ans == False:
		break
if ans == True:
	print('Yes')
else:
	print('No')


n = int(input())
ls = []
for i in range(n):
	l = list(map(int, input().strip().split(' ')))
	ls.append(l)
for i in range(n):
	for j in range(n):
		if ls[i][j] != 1:
			flag = False
			for k in range(n):
				for l in range(n):
					if ls[i][k] + ls[l][j] == ls[i][j] and k != j and (i != l):
						flag = True
			if flag == False:
				print('No')
				exit()
print('Yes')


n = int(input().split()[0])
tab = [[] for _ in range(n)]
for i in range(n):
	for inp in input().rstrip().split():
		tab[i].append(int(inp))
tabt = list(map(list, zip(*tab)))
cnt = 0
for (i, line) in enumerate(tab):
	for (j, column) in enumerate(tabt):
		for a in line:
			for b in column:
				if tab[i][j] == 1 or tab[i][j] == a + b:
					cnt += 1
					break
			else:
				continue
			break
if cnt == n * n:
	print('YES')
else:
	print('NO')


import os
import sys
from io import BytesIO, IOBase
import math
from decimal import Decimal
from decimal import *
from collections import defaultdict, deque
import heapq
from decimal import Decimal
getcontext().prec = 25
abcd = 'abcdefghijklmnopqrstuvwxyz'
ABCD = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
months = {1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31}
MOD = 1000000007
BUFSIZE = 8192
from bisect import bisect_left, bisect_right

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
l = []
for i in range(n):
	l.append(list(map(int, input().split(' '))))
ans = 'YES'
for i in range(n):
	if ans == 'NO':
		break
	for j in range(n):
		if l[i][j] == 1:
			continue
		ans = 'NO'
		f = set()
		for k in range(n):
			if k != i:
				f.add(l[k][j])
		z = set()
		for kk in range(n):
			if kk != j:
				z.add(l[i][kk])
		for zz in z:
			for ff in f:
				if ff + zz == l[i][j]:
					ans = 'YES'
		if ans == 'NO':
			break
print(ans)


import sys

def lab():
	N = int(input())
	nList = []
	for x in range(N):
		S = input()
		nList.append([int(i) for i in S.split()])
	for a in range(N):
		for b in range(N):
			phase = 0
			if nList[a][b] == 1:
				pass
			else:
				vrList = [i for i in nList[a]]
				vcList = [nList[t][b] for t in range(N)]
				if nList[a][b] in vrList:
					vrList.remove(nList[a][b])
				if nList[a][b] in vcList:
					vcList.remove(nList[a][b])
				vrList.sort()
				vcList.sort()
				if len(vrList) == 0 or len(vcList) == 0:
					print('No')
					sys.exit()
				(i, j) = (0, len(vrList) - 1)
				while i <= j:
					sum = vrList[i] + vcList[j]
					if sum == nList[a][b]:
						phase = 1
						break
					elif sum > nList[a][b]:
						j -= 1
					else:
						i += 1
					if i > j:
						phase = 2
						pass
				(i, j) = (len(vcList) - 1, 0)
				while i >= j and phase == 2:
					sum = vrList[i] + vcList[j]
					if sum == nList[a][b]:
						break
					elif sum > nList[a][b]:
						i -= 1
					else:
						j += 1
					if i < j:
						print('No')
						sys.exit()
	print('Yes')
lab()


import sys

def main():
	n = int(input())
	x = []
	for i in range(n):
		y = list(map(int, sys.stdin.readline().split()))
		x.append(y)
	for i in range(n):
		for j in range(n):
			if x[i][j] == 1:
				continue
			found = False
			for o in range(n):
				a = x[i][o]
				if o == j:
					continue
				for p in range(n):
					if p == i:
						continue
					b = x[p][j]
					if a + b == x[i][j]:
						found = True
						break
				if found:
					break
			if not found:
				print('No')
				return
	print('Yes')
main()


def list_input():
	return list(map(int, input().split()))
n = int(input())
a = list()
for i in range(n):
	a.append(list_input())
for i in range(n):
	for j in range(n):
		if a[i][j] == 1:
			continue
		found = False
		for p in range(n):
			for q in range(n):
				if a[i][p] + a[q][j] == a[i][j] and p != j and (q != i):
					found = True
					break
			if found:
				break
		if not found:
			print('No')
			exit(0)
print('Yes')


t = []
s = []
a = int(input())
for k in range(a):
	t.append(list(map(int, input().split())))
for j in range(a):
	p = []
	for y in range(a):
		p.append(t[y][j])
	s.append(p)
h = 0
for b in range(a):
	for c in range(a):
		if t[b][c] != 1:
			z = 0
			l = t[b][c]
			for v in range(1, l):
				if v in t[b]:
					if l - v in s[c]:
						z += 1
				if v in s[c]:
					if l - v in t[b]:
						z += 1
			if z == 0:
				print('No')
				h += 1
				break
		if h > 0:
			break
	if h > 0:
		break
if h == 0:
	print('Yes')


def bsearh(arr, val):
	arr.sort()
	mid = (n - 1) // 2
	l = 0
	r = n - 1
	while l < r:
		if arr[mid] == val:
			return 1
		elif arr[mid] < val:
			r = mid + 1
		else:
			l = mid - 1
	return 0
n = int(input())
arr = []
for i in range(n):
	arr1 = list(map(int, input().split()))
	arr.append(arr1)
flag = 0
for i in range(n):
	for j in range(n):
		if arr[i][j] != 1:
			flag1 = 0
			for k in range(n):
				for l in range(n):
					if arr[i][k] + arr[l][j] == arr[i][j]:
						flag1 = 1
						break
				if flag1 == 1:
					break
			if flag1 == 0:
				flag = 1
				break
	if flag != 0:
		break
if flag == 0:
	print('YES')
else:
	print('NO')


n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
for (i, ai) in enumerate(a):
	for (j, aij) in enumerate(ai):
		if aij == 1 or any((aij - a[k][j] in ai for k in range(n))):
			continue
		print('No')
		exit()
print('Yes')


grid = []
N = int(input())
for nn in range(N):
	line = input()
	tmp = [int(x) for x in line.split()]
	grid.append(tmp)

def CheckGoodness(i, j, N):
	total = grid[i][j]
	row_nums = []
	col_nums = []
	for k in range(N):
		row_nums.append(grid[i][k])
		col_nums.append(grid[k][j])
	res = False
	for ki in row_nums:
		for kj in col_nums:
			if ki + kj == total:
				res = True
	return res
for i in range(N):
	for j in range(N):
		if grid[i][j] != 1:
			if not CheckGoodness(i, j, N):
				print('No')
				quit()
print('Yes')


def user_input():
	n = input()
	n = n.split()
	n = list(map(int, n))
	n = n[0]
	matrix = list()
	for i in range(0, n):
		str2 = input()
		str2 = str2.split()
		str2 = list(map(int, str2))
		matrix.append(str2)
	fun(n, matrix)

def fun(n, matrix):
	for y in range(0, n):
		for x in range(0, n):
			if matrix[y][x] == 1:
				continue
			elif findel(matrix, n, y, x):
				pass
			else:
				print('No')
				return
	print('Yes')

def findel(matrix, n, y, x):
	for s in range(0, n):
		for t in range(0, n):
			if matrix[y][x] == matrix[s][x] + matrix[y][t]:
				return True
	return False
user_input()


n = int(input())
a = []
o = True
for _ in range(n):
	a += [[int(f) for f in input().split()]]
for x in range(n):
	for y in range(n):
		s = False
		tr = list(range(n))
		tc = list(range(n))
		tr.remove(x)
		tc.remove(y)
		if a[x][y] != 1:
			for r in tr:
				for c in tc:
					if a[r][y] + a[x][c] == a[x][y]:
						s = True
		else:
			s = True
		if s == False:
			print('NO')
			exit()
print('YES')


n = int(input())
tbl = []
for i in range(n):
	tbl.append(list(map(int, input().split())))
out = False
for (i, row) in enumerate(tbl):
	for j in range(len(row)):
		out = False
		e = row[j]
		if e == 1:
			out = True
			continue
		for (j1, e1) in enumerate(row):
			if j1 != j:
				for i1 in range(n):
					if e1 + tbl[i1][j] == e:
						out = True
						break
			if out:
				break
		if not out:
			print('No')
			break
	if not out:
		break
if out:
	print('Yes')


n = int(input())
l = []
for i in range(n):
	l.append(list(map(int, input().split())))
(a, b) = (0, 0)
for i in range(len(l)):
	for j in range(len(l)):
		if l[i][j] != 1:
			a += 1
			for k in range(len(l)):
				flag = 0
				for m in range(len(l)):
					if l[i][k] == l[i][j] or l[m][j] == l[i][j]:
						continue
					if l[i][k] + l[m][j] == l[i][j]:
						b += 1
						flag = 1
						break
				if flag == 1:
					break
if a == b:
	print('Yes')
else:
	print('No')


n = int(input())
lab = [[int(s) for s in input().split(' ')] for i in range(n)]
db = False
for i in range(n):
	if db:
		break
	for j in range(n):
		elem = lab[i][j]
		if elem == 1:
			answer = True
		else:
			answer = False
			for k in range(n):
				for l in range(n):
					if k != i and l != j and (lab[i][l] + lab[k][j] == elem):
						answer = True
		if not answer:
			db = True
			break
if answer:
	print('Yes')
else:
	print('No')


n = int(input())
a = []
for i in range(n):
	a += [list(map(int, input().split()))]
for i in range(n):
	for j in range(n):
		b = a[i][j]
		if b != 1:
			for k in range(n):
				if b - a[k][j] in a[i]:
					b = 0
					break
			if b:
				print('No')
				quit()
print('Yes')


n = int(input())
l = []
s1 = 0
c = 1
for i in range(n):
	l.append(list(map(int, input().split())))
if n == 1:
	if l[0][0] == 1:
		print('Yes')
	else:
		print('No')
else:
	s = list(zip(*l))
	for i in range(n):
		for j in range(n):
			if l[i][j] != 1:
				s1 = 0
				c = 0
				for z in range(n):
					if l[i][j] - l[i][z] in s[j]:
						c = 1
						break
				if c == 0:
					s1 = 0
					break
				else:
					s1 = 1
		if c == 0:
			s1 = 0
			break
	if s1 == 0:
		print('No')
	else:
		print('Yes')


n = int(input())
(l, d, f) = ([], 0, 0)
for i in range(n):
	l.append(list(map(int, input().split())))
for i in range(n):
	for j in range(n):
		if l[i][j] > 1:
			flag = 0
			d += 1
			for k in range(n):
				for p in range(n):
					if l[i][p] + l[k][j] == l[i][j]:
						f += 1
						flag = 1
						break
				if flag == 1:
					break
print(['NO', 'YES'][d == f])


from sys import exit
n = int(input())
l = []
for i in range(n):
	l.append(list(map(int, input().split())))
for i in range(n):
	for j in range(n):
		if l[i][j] != 1:
			flag = False
			for d in range(n):
				for k in range(n):
					if d != j and k != i and (l[i][d] + l[k][j] == l[i][j]):
						flag = True
			if not flag:
				print('NO')
				exit(0)
print('YES')


from math import *
from cmath import *
from itertools import *
from decimal import *
from fractions import *
from sys import *
from types import CodeType, new_class
n = int(input())
a = []
for x in range(n):
	a.append([int(y) for y in input().split()])
for x in range(n):
	for y in range(n):
		if a[x][y] == 1:
			continue
		ok = 0
		for z in range(n):
			if z == x:
				continue
			for r in range(n):
				if r == y:
					continue
				ok = int(a[x][y] - a[x][r] - a[z][y] == 0)
				if ok:
					break
			if ok:
				break
		if not ok:
			print('NO')
			exit(0)
print('YES')


read = lambda : map(int, input().split())
n = int(input())
a = [list(read()) for i in range(n)]
for i in range(n):
	for j in range(n):
		if a[i][j] != 1:
			for k in range(n):
				if a[i][j] - a[k][j] in a[i]:
					break
			else:
				print('No')
				exit()
print('Yes')


n = int(input())
arr = [list(map(int, input().split())) for i in range(n)]
for i in range(n):
	for j in range(n):
		if arr[i][j] != 1:
			cnt = 0
			for k in range(n):
				for l in range(n):
					if arr[i][k] + arr[l][j] == arr[i][j]:
						cnt += 1
			if cnt == 0:
				print('No')
				exit(0)
print('Yes')


n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
for i in range(n):
	for j in range(n):
		if a[i][j] != 1:
			value = False
			for i1 in range(n):
				for j1 in range(n):
					if a[i][j1] + a[i1][j] == a[i][j]:
						value = True
			if value == False:
				print('No')
				exit(0)
print('Yes')


n = int(input())
M = [list(map(int, input().split())) for i in range(n)]
for i in range(n):
	for j in range(n):
		if M[i][j] != 1:
			c = 1
			for i1 in range(n):
				for j1 in range(n):
					if M[i][j] == M[i1][j] + M[i][j1]:
						c = 0
						break
			if c == 1:
				print('No')
				exit()
print('Yes')


I = lambda : map(int, input().split())
(n,) = I()
arr = []
for i in range(0, n):
	arr.append(list(I()))
for x in range(0, n):
	for y in range(0, n):
		if arr[x][y] != 1:
			found = False
			for s in range(0, n):
				for t in range(0, n):
					if arr[x][y] == arr[x][s] + arr[t][y]:
						found = True
			if not found:
				print('No')
				return
print('Yes')


n = int(input())
lab = [[int(i) for i in input().split()] for j in range(n)]

def check(lab, x, y, n):
	rowcheck = lab[y][:x] + lab[y][x + 1:]
	colcheck = [lab[i][x] for i in range(n) if i != y]
	sums = [rowcheck[s] + colcheck[t] for s in range(n - 1) for t in range(n - 1)]
	if lab[y][x] in sums or lab[y][x] == 1:
		return True
	else:
		return False
good = []
for x in range(n):
	for y in range(n):
		if check(lab, x, y, n):
			good.append(True)
		else:
			good.append(False)
if False in good:
	print('no')
else:
	print('yes')


import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def LS():
	return sys.stdin.readline().split()

def S():
	return input()

def main():
	n = I()
	l = [LI() for _ in range(n)]
	for i in range(n):
		for j in range(n):
			x = l[i][j]
			if x == 1:
				continue
			d = {}
			for k in range(n):
				if k != j:
					d[l[i][k]] = l[i][k]
			f = False
			for k in range(n):
				if k != i:
					if x - l[k][j] in d:
						f = True
			if not f:
				return 'No'
	return 'Yes'
print(main())


import random
import math
import sys
n = int(input())
l = [[0 for x in range(n)] for y in range(n)]
for i in range(0, n):
	t = [int(x) for x in input().split()]
	for j in range(0, n):
		l[i][j] = t[j]
flag = 0
for i in range(0, n):
	for j in range(0, n):
		if l[i][j] != 1:
			flag = 0
			for k in range(0, n):
				if k == j:
					continue
				else:
					value = l[i][k]
					for s in range(0, n):
						if s == i:
							continue
						else:
							test = l[s][j]
							if value + test == l[i][j]:
								flag = 1
								break
				if flag == 1:
					break
			if flag == 0:
				print('NO')
				sys.exit()
print('YES')


n = int(input())
a = []
for i in range(n):
	a.append(list(map(int, input().split())))
ok = True
for i in range(n):
	for j in range(n):
		if a[i][j] != 1:
			check = False
			for k in range(n):
				for l in range(n):
					if a[i][j] == a[i][k] + a[l][j]:
						check = True
					if check:
						break
				if check:
					break
			ok &= check
print('Yes' if ok else 'No')


n = int(input())
arr = [list(map(int, input().split())) for i in range(n)]
fl = 1
for i in range(n):
	if not fl:
		break
	for j in range(n):
		if arr[i][j] != 1 and fl:
			for k in range(n):
				fa = 0
				if arr[i][j] - arr[k][j] in arr[i]:
					fa = 1
					break
			fl = fa
print('YES' if fl else 'NO')


def checker(x, n, a, b):
	for i in range(n):
		for j in range(n):
			if a[i] + b[j] == x:
				return True
			else:
				continue
n = int(input())
l = []
for i in range(n):
	a = list(map(int, input().split()))
	l.append(a)
z = 0
for i in range(n):
	for j in range(n):
		x = l[i][j]
		b = l[i]
		c = []
		for k in range(n):
			c.append(l[k][j])
		if x == 1:
			continue
		elif checker(x, n, b, c):
			continue
		else:
			z = 1
			break
	if z == 1:
		break
if z == 1:
	print('No')
else:
	print('Yes')


n = int(input())
a = []
i = 0
while i < n:
	temp = list(map(int, input().strip().split(' ')))
	a.append(temp)
	i += 1
count = 0
skipLoop = False
for i in range(0, n):
	for j in range(0, n):
		if a[i][j] == 1:
			count += 1
		else:
			for k in range(0, n):
				for l in range(0, n):
					if l != i and j != k:
						if a[i][k] + a[l][j] == a[i][j]:
							count += 1
							skipLoop = True
							break
				if skipLoop:
					skipLoop = False
					break
if count == n * n:
	print('Yes')
else:
	print('No')


n = int(input())
arr = []
for i in range(n):
	arr.append([int(j) for j in input().split()])

def isThere(i, j, n):
	for x in range(n):
		for y in range(n):
			if arr[x][j] + arr[i][y] == arr[i][j]:
				return True
	return False
answer = 'Yes'
for i in range(n):
	for j in range(n):
		if not arr[i][j] == 1:
			if not isThere(i, j, n):
				answer = 'No'
print(answer)


n = int(input())
p = [list(map(int, input().split())) for _ in range(n)]
for (i, A) in enumerate(p):
	for (j, B) in enumerate(A):
		if B == 1 or any((B - p[t][j] in A for t in range(n))):
			continue
		print('NO')
		exit()
print('YES')


import sys

def main():
	iterator = iter(sys.stdin.read().split())
	n = int(next(iterator))
	a = [[0] * n for _ in range(n)]
	for i in range(n):
		for j in range(n):
			a[i][j] = int(next(iterator))
	for i in range(n):
		for j in range(n):
			x = a[i][j]
			if x == 1:
				continue
			flag = False
			for p in range(n):
				for q in range(n):
					if a[i][p] + a[q][j] == x:
						flag = True
			if not flag:
				print('No')
				return
	print('Yes')
main()


import sys
from sys import stdin, stdout
import bisect
from bisect import bisect_left as bl
from bisect import bisect_right as br
import itertools
from collections import Counter
import collections
import math
import heapq
import re

def modinv(n, p):
	return pow(n, p - 2, p)

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l

def most_frequent(list):
	return max(set(list), key=list.count)

def GCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def ncr(n, r, p):
	t = fact[n] * (ifact[r] * ifact[n - r] % p) % p
	return t

def Convert(string):
	li = list(string.split(''))
	return li

def SieveOfEratosthenes(n):
	global prime
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	f = []
	for p in range(2, n):
		if prime[p]:
			f.append(p)
	return f
prime = []
q = []

def dfs(n, d, v, c):
	global q
	v[n] = 1
	x = d[n]
	q.append(n)
	j = c
	for i in x:
		if i not in v:
			f = dfs(i, d, v, c + 1)
			j = max(j, f)
	return j

def main():
	n = int(input())
	a = []
	for i in range(n):
		a.append(ain())
	f = 0
	for i in range(n):
		for j in range(n):
			if a[i][j] == 1:
				continue
			t = 0
			for g in range(n):
				for h in range(n):
					if a[i][g] + a[h][j] == a[i][j]:
						t = 1
						break
				if t == 1:
					break
			if t == 0:
				f = 1
				break
		if f == 1:
			break
	if f == 0:
		print('Yes')
	else:
		print('No')
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())
r = []
for i in range(n):
	s = input().split()
	for val in range(len(s)):
		s[val] = int(s[val])
	r.append(s)
flag = 0
for i in range(n):
	for j in range(n):
		flag = 0
		if r[i][j] == 1:
			flag = 1
			continue
		for k in range(n):
			for l in range(n):
				if r[i][k] + r[l][j] == r[i][j]:
					flag = 1
		if flag == 0:
			print('No')
			break
	if flag == 0:
		break
if flag == 1:
	print('Yes')


m = [list(map(int, input().split())) for _ in range(int(input()))]
(t, r) = (list(map(set, zip(*m))), True)
for row in m:
	r &= all((x < 2 or any((x - a in c for a in row)) for (x, c) in zip(row, t)))
print(('No', 'Yes')[r])


n = int(input())

def get_row(i, j):
	return matrix[i]

def get_col(i, j):
	return [matrix[k][j] for k in range(n)]
matrix = []
for i in range(n):
	matrix.append(list(map(int, input().split())))
valid = True
for i in range(n):
	if not valid:
		break
	for j in range(n):
		if matrix[i][j] != 1:
			row = get_row(i, j)
			col = get_col(i, j)
			exist = False
			for k in row:
				for l in col:
					if k + l == matrix[i][j]:
						exist = True
						break
			if not exist:
				valid = False
				break
if valid:
	print('YES')
else:
	print('NO')


n = int(input())
h = [[int(i) for i in input().split()] for j in range(n)]
g = False
for i in range(len(h)):
	for j in range(len(h)):
		if h[i][j] != 1:
			s = h[i][j]
			g = False
			for o in range(n):
				a = h[i][o]
				for p in range(n):
					b = h[p][j]
					if a + b == s:
						g = True
						break
				if g:
					break
			else:
				print('No')
				exit()
print('YES')


n = int(input())
l = []
for i in range(n):
	l.append(list(map(int, input().split())))
ind = []
for i in range(n):
	for j in range(n):
		if l[i][j] != 1:
			ind.append([i, j])
check = []
for [i, j] in ind:
	flag = 0
	for x in range(n):
		for y in range(n):
			if l[i][x] + l[y][j] == l[i][j]:
				check.append('Yes')
				flag = 1
				break
		if flag == 1:
			break
if len(check) == len(ind):
	print('Yes')
else:
	print('No')


n = int(input())
x = []
for i in range(n):
	x.append(list(map(int, input().split())))
flag1 = False
for i in range(n):
	for j in range(n):
		if x[i][j] != 1:
			flag2 = False
			for k in range(n):
				for l in range(n):
					if k != i or l != j:
						if x[k][j] + x[i][l] == x[i][j]:
							flag2 = True
							break
				if flag2:
					break
			if not flag2:
				flag1 = True
				print('no')
				break
	if flag1:
		break
if not flag1:
	print('yes')


n = int(input())
arr = []
for i in range(n):
	arr.append(list(map(int, input().split())))
f = True
for i in range(n):
	for j in range(n):
		if arr[i][j] > 1:
			b = False
			for k in range(n):
				for l in range(n):
					if arr[i][j] == arr[i][k] + arr[l][j]:
						b = True
			if not b:
				f = False
print('Yes' if f else 'No')


n = int(input())
L = [list(map(int, input().split())) for _ in range(n)]
for (i, X) in enumerate(L):
	for (j, Y) in enumerate(X):
		if Y == 1 or any((Y - L[t][j] in X for t in range(n))):
			continue
		print('NO')
		exit()
print('YES')


import sys

def main():
	inp = sys.stdin.read().strip().split('\n')
	n = int(inp[0])
	l1 = [[int(i) for i in j.split()] for j in inp[1:]]
	l2 = list(zip(*l1))
	for i in range(n):
		for j in range(n):
			if l1[i][j] != 1:
				if all((l1[i][j] - t not in l2[j][:i] + l2[j][i + 1:] for t in l1[i][:j] + l1[i][j + 1:])):
					return 'No'
	return 'Yes'
print(main())


n = int(input())
grid = []
for i in range(n):
	grid.append(list(map(int, input().split())))
good = True
for i in range(n):
	for j in range(n):
		if grid[i][j] == 1:
			continue
		else:
			foundSum = False
			for s in range(n):
				for t in range(n):
					if grid[i][s] + grid[t][j] == grid[i][j]:
						foundSum = True
						break
				if foundSum:
					break
			if not foundSum:
				good = False
		if not good:
			break
	if not good:
		break
if good:
	print('Yes')
else:
	print('No')


Size = int(input())
Matrix = list()
for i in range(Size):
	Matrix.append(list(map(int, input().split())))
for i in range(Size):
	for j in range(Size):
		Stop = False
		if Matrix[i][j] != 1:
			for t in range(Size):
				for s in range(Size):
					if i != t and s != j:
						if Matrix[i][j] == Matrix[i][s] + Matrix[t][j]:
							Stop = True
							break
				if Stop == True:
					break
			if Stop == False:
				print('NO')
				exit()
print('YES')


n = int(input())
l_r = list()
for _ in range(n):
	l_r.append([int(x) for x in input().split()])
l_s_c = list((set() for _ in range(n)))
l_s_r = list((set() for _ in range(n)))
for i in range(n):
	for j in range(n):
		l_s_c[j].add(l_r[i][j])
		l_s_r[i].add(l_r[i][j])
for i in range(n):
	for j in range(n):
		if l_r[i][j] == 1:
			continue
		f = False
		for v in l_s_c[j]:
			if l_r[i][j] - v in l_s_r[i]:
				f = True
				break
		if not f:
			print('No')
			quit()
print('Yes')


n = int(input())
rows = []
for x in range(n):
	string = input()
	row = string.split(' ')
	for y in range(n):
		row[y] = int(row[y])
	rows.append(row)
columns = []
for x in range(n):
	column = []
	for y in range(n):
		column.append(rows[y][x])
	columns.append(column)
results = 'Yes'
for x in range(n):
	a = 0
	while a < n:
		r = rows[x][a]
		if r != 1:
			b = 0
			while b < n:
				c = columns[a][b]
				s = 0
				while s < n:
					t = rows[x][s]
					condition = b == x and s == y
					if c == r - t and (not condition):
						break
					s += 1
				if s != n:
					break
				b += 1
			if b == n:
				break
		a += 1
	if a != n:
		results = 'No'
		break
print(results)


from itertools import chain
i = lambda : [*map(int, input().split())]
n = i()[0]
a = [i() for _ in [0] * n]
b = [*zip(*a)]
print('NYOE S'[all((x < 2 or any((x == y + z for y in a[i // n] for z in b[i % n])) for (i, x) in enumerate(chain(*a))))::2])


n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
b = list(zip(*a))
for r in range(n):
	for c in range(n):
		if a[r][c] != 1:
			if not any((a[r][c] - x in list(b[c]) for x in a[r])):
				print('NO')
				quit()
print('YES')


n = int(input())
l = [list(map(int, input().split())) for i in range(n)]
c = []
for i in range(n):
	cul = []
	for u in range(n):
		cul.append(l[u][i])
	c.append(cul)

def is_good(i, j):
	if l[i][j] == 1:
		return True
	row = l[i][:j] + l[i][j + 1:]
	cul = c[j][:i] + c[j][i + 1:]
	for a in row:
		if l[i][j] - a in cul:
			return True
	return False

def f():
	for i in range(n):
		for j in range(n):
			if not is_good(i, j):
				print('No')
				return
	print('Yes')
f()


import itertools
import bisect
import math
from collections import *
import os
import sys
from io import BytesIO, IOBase
ii = lambda : int(input())
lmii = lambda : list(map(int, input().split()))
slmii = lambda : sorted(map(int, input().split()))
li = lambda : list(input())
mii = lambda : map(int, input().split())
msi = lambda : map(str, input().split())

def main():
	n = ii()
	a = []
	for i in range(n):
		a.append(lmii())
	f = 0
	for i in range(n):
		for j in range(n):
			if a[i][j] == 1:
				f += 1
	if f == n * 1000000000:
		print('No')
	else:
		for i in range(n):
			for j in range(n):
				f = 0
				if a[i][j] != 1:
					for k in range(n):
						for l in range(n):
							if a[k][j] + a[i][l] == a[i][j]:
								f = 1
								break
						if f == 1:
							break
					if f == 0:
						print('No')
						exit(0)
		print('Yes')
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def run(a, n):
	flag = 0
	for i in range(n):
		for j in range(n):
			flag = 0
			if a[i][j] == 1:
				flag = 1
			for p in range(n):
				for q in range(n):
					if a[i][p] + a[q][j] == a[i][j]:
						flag = 1
			if flag != 1:
				print('No')
				return
	print('Yes')
n = int(input())
a = []
for _ in range(n):
	a.append(list(map(int, input().split())))
run(a, n)


n = int(input())
l = []
d = []
b = 0
for i in range(n):
	r = list(map(int, input().split()))
	l.append(r)
for i in range(n):
	for j in range(n):
		t = 0
		x = l[i][j]
		if x == 1:
			continue
		else:
			for k in range(n):
				q = l[i][k]
				for h in range(n):
					g = l[h][j]
					if x == q + g:
						t += 1
						break
		if t == 0:
			b += 1
if b == 0:
	print('YES')
else:
	print('NO')


IL = lambda : list(map(int, input().split()))
IS = lambda : input().split()
I = lambda : int(input())
S = lambda : input()
n = I()
grid = [IL() for i in range(n)]
ans = True
for i in range(n):
	for j in range(n):
		if grid[i][j] == 1:
			continue
		set1 = set([grid[i][j] - grid[ii][j] for ii in range(n)])
		set2 = set([grid[i][jj] for jj in range(n)])
		if len(set1.intersection(set2)) == 0:
			ans = False
print('Yes' if ans else 'No')


import sys
input = sys.stdin.readline
n = int(input())
grid = []
for i in range(n):
	grid.append([int(x) for x in input().split()])
for i in range(n):
	for j in range(n):
		if grid[i][j] == 1:
			continue
		found = False
		for x in range(n):
			for y in range(n):
				if grid[i][x] + grid[y][j] == grid[i][j]:
					found = True
					break
		if not found:
			print('No')
			exit()
print('Yes')


n = input()
n = int(n)
a = [[int(j) for j in input().strip().split()] for i in range(n)]
for i in range(n):
	for j in range(n):
		thereisNum = False
		if a[i][j] > 1:
			for k in range(n):
				for m in range(n):
					if a[k][j] + a[i][m] == a[i][j]:
						thereisNum = True
						break
				if thereisNum == True:
					break
			if thereisNum == False:
				print('No')
				quit()
print('Yes')


n = int(input())
l = []
for i in range(n):
	l.append(list(map(int, input().split())))
for i in range(n):
	for j in range(n):
		if l[i][j] != 1:
			for k in range(n):
				if l[i][j] - l[k][j] in l[i]:
					break
			else:
				print('No')
				exit()
print('Yes')


n = int(input())
l = []
for i in range(n):
	l.append([int(j) for j in input().split()])
if n == 1 and l[0][0] == 1:
	print('Yes')
elif n == 1 and l[0][0] != 1:
	print('No')
else:
	f = 0
	for i in range(n):
		for j in range(n):
			flag = 0
			if l[i][j] != 1:
				for k in range(n):
					for m in range(n):
						if k != j or m != j:
							if l[i][j] == l[k][j] + l[i][m]:
								flag = 1
								break
					if flag == 1:
						break
				if flag == 0:
					f = 1
					break
		if f == 1:
			break
	if f == 1:
		print('No')
	else:
		print('Yes')


n = int(input())
a = []
for i in range(n):
	a.append(list(map(int, input().split())))
answer = 'Yes'
for i in range(n):
	for j in range(n):
		if a[i][j] == 1:
			continue
		cur = 'No'
		for c in range(n):
			for k in range(n):
				if a[c][j] + a[i][k] == a[i][j]:
					cur = 'Yes'
		if cur == 'No':
			answer = 'No'
print(answer)


n = int(input())
ma = []
ans = True
for i in range(n):
	row = list(map(int, input().split()))
	ma.append(row)
for i in range(n):
	for j in range(n):
		if ma[i][j] != 1:
			find = False
			d = {}
			for x in range(n):
				if x != j:
					dif = ma[i][j] - ma[i][x]
					d[dif] = 1
			for x in range(n):
				if x != i and ma[x][j] in d:
					find = True
			if not find:
				ans = False
if ans:
	print('Yes')
else:
	print('No')


alph = 'abcdefghijklmnopqrstuvwxyz'
n = int(input())
t = []
flag = True
for i in range(n):
	t.append(list(map(int, input().split())))
for i in range(n):
	for j in range(n):
		if t[i][j] == 1:
			continue
		else:
			p = False
			for x in range(n):
				if p:
					break
				for y in range(n):
					if x != j and y != i:
						if t[y][j] + t[i][x] == t[i][j]:
							p = True
							break
				if p:
					break
			else:
				flag = False
if flag:
	print('Yes')
else:
	print('No')


def main():
	read = lambda : tuple(map(int, input().split()))
	R = range(read()[0])
	m = [read() for i in R]
	(b, d) = (0, 0)
	for x in R:
		for y in R:
			if m[y][x] > 1:
				b += 1
				f = False
				for t in R:
					if f:
						break
					for s in R:
						if m[y][x] == m[y][s] + m[t][x]:
							d += 1
							f = True
							break
	print('Yes' if b == d else 'No')
main()


n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
s = list(map(set, a))
flag = 0
for i in range(n):
	for j in range(n):
		if a[i][j] != 1:
			f = 0
			for k in range(n):
				if a[i][j] - a[k][j] in s[i]:
					f = 1
					break
			if f == 0:
				flag = 1
				break
	if flag == 1:
		break
if flag == 1:
	print('NO')
else:
	print('YES')


def is_good(a, n, i, j):
	c = set([])
	for x in range(n):
		c.add(a[i][j] - a[i][x])
	for x in range(n):
		if a[x][j] in c:
			return True
	return False
n = int(input())
a = []
for _ in range(n):
	a.append([int(x) for x in input().strip().split(' ')])
good = True
for i in range(n):
	for j in range(n):
		if a[i][j] != 1 and (not is_good(a, n, i, j)):
			good = False
			break
if good:
	print('Yes')
else:
	print('No')


n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
for i in range(n):
	for j in range(n):
		flag = 0
		if a[i][j] == 1:
			continue
		for k in range(n):
			for kk in range(n):
				if a[i][k] + a[kk][j] == a[i][j]:
					flag = 1
					break
			if flag:
				break
		if not flag:
			print('No')
			exit(0)
print('Yes')


import sys

def main(input):
	n = int(next(input))
	matrix = []
	for _ in range(n):
		matrix.append(list(map(int, next(input).split())))
	failed = False
	for i in range(n):
		for j in range(n):
			if matrix[i][j] == 1:
				continue
			found = False
			for x in range(n):
				for y in range(n):
					if matrix[i][x] + matrix[y][j] == matrix[i][j]:
						found = True
			if not found:
				failed = True
	print('Yes' if not failed else 'No')
main(iter(sys.stdin.readlines()))


def check(i, j, l, n):
	for rows in range(n):
		for columns in range(n):
			if rows != j and columns != i:
				if l[i][rows] + l[columns][j] == l[i][j]:
					return False
	return True
n = int(input())
l = []
for i in range(n):
	l += [list(map(int, input().split()))]
flag = 0
for i in range(n):
	for j in range(n):
		if l[i][j] != 1 and check(i, j, l, n):
			flag = 1
			break
	if flag == 1:
		print('NO')
		break
else:
	print('YES')


def main():
	N = int(input())
	A = []
	import bisect
	for _ in range(N):
		A += [list(map(int, input().strip().split(' ')))]
	check = 1
	for i in range(N):
		if check == 0:
			break
		for j in range(N):
			if check == 0:
				break
			if A[i][j] != 1:
				temp = sorted(A[i])
				OK = 0
				for k in range(N):
					remain = A[i][j] - A[k][j]
					if remain > 0:
						if bisect.bisect_left(temp, remain) != bisect.bisect_right(temp, remain):
							OK = 1
							break
				if OK == 0:
					check = 0
					break
	if check == 0:
		print('No')
	else:
		print('Yes')
main()


n = int(input())
l = []
for i in range(n):
	l.append(list(map(int, input().split())))
for i in range(n):
	for x in range(n):
		if l[i][x] != 1:
			c = 0
			for j in range(n):
				if j == x:
					continue
				for k in range(n):
					if k == i:
						continue
					if l[i][j] + l[k][x] != l[i][x]:
						c += 1
			if c == (n - 1) ** 2:
				print('No')
				exit()
print('Yes')


(n,) = map(int, input().split())
arr = []
for _ in range(n):
	arr.append(list(map(int, input().split())))
row = [set() for _ in range(n)]
col = [set() for _ in range(n)]
data = []
for i in range(n):
	for j in range(n):
		data.append([arr[i][j], i, j])
data.sort()
ans = 'YES'
for (v, r, c) in data:
	if v > 1:
		for rt in row[r]:
			if v - rt in col[c]:
				break
		else:
			ans = 'NO'
			break
	row[r].add(v)
	col[c].add(v)
print(ans)


n = int(input())
a = []
for i in range(n):
	a.append(list(map(int, input().split())))
t = True
i = 0
while i < n and t:
	j = 0
	while j < n and t:
		s = 0
		q = False
		while s < n and t and (not q):
			r = 0
			while r < n and t and (not q):
				if a[i][j] == a[i][s] + a[r][j] and a[i][j] != 1:
					q = True
				elif a[i][j] == 1:
					q = True
				r += 1
			s += 1
		if q == False:
			t = False
		j += 1
	i += 1
if t == True:
	print('Yes')
else:
	print('No')


a = []
x = int(input())
for i in range(x):
	a.append(list(map(int, input().split())))
for i in range(x):
	b = []
	for t in range(x):
		k = -1
		if a[i][t] > 1:
			b = [a[k][t] for k in range(x) if a[k][t] < a[i][t]]
			for v in range(x):
				if a[i][v] < a[i][t] and a[i][t] - a[i][v] in b:
					k = 1
					break
			if k != 1:
				exit(print('No'))
print('YES')


n = int(input())
arr = []
for i in range(n):
	arr.append(list(map(int, input().split())))

def get_x(i, n, arr):
	return arr[i][n]

def get_y(j, n, arr):
	return arr[n][j]

def is_good(i, j, arr, n):
	for k in range(n):
		for p in range(n):
			if get_x(i, k, arr) + get_y(j, p, arr) == arr[i][j] and (j != k and i != p):
				return True
	return False
res = 'YES'
for i in range(n):
	for j in range(n):
		if is_good(i, j, arr, n) or arr[i][j] == 1:
			pass
		else:
			res = 'NO'
print(res)


cases = int(input())
n = cases
matrix = []
while cases:
	cases -= 1
	row = list(map(int, input().split()))
	matrix.append(row)
for i in range(n):
	for j in range(n):
		if matrix[i][j] == 1:
			continue
		broken = False
		for k in range(n):
			for m in range(n):
				if matrix[i][k] + matrix[m][j] == matrix[i][j]:
					broken = True
		if not broken:
			print('No')
			exit()
print('Yes')


n = int(input())
laboratory = [[int(number) for number in input().split()] for _ in range(n)]

def get_row(i):
	return list(laboratory[i])

def get_col(i):
	return [laboratory[j][i] for j in range(n)]

def get_except(lst, i):
	return lst[:i] + lst[i + 1:]

def good_lab():
	for i in range(n):
		for j in range(n):
			this_val = laboratory[i][j]
			if this_val != 1:
				row_vals = get_except(get_row(i), j)
				col_vals = get_except(get_col(j), i)
				if not any([this_val - r in col_vals for r in row_vals]):
					return False
	return True
print('Yes') if good_lab() else print('No')


n = input()
n = int(n)
Matrix = [[0 for x in range(n)] for y in range(n)]
for i in range(n):
	inp = input()
	inp = inp.split(' ')
	for j in range(n):
		Matrix[i][j] = int(inp[j])
noflag = False
for i in range(n):
	for j in range(n):
		if Matrix[i][j] > 1:
			ans = False
			for k in range(n):
				for l in range(n):
					if Matrix[i][j] == Matrix[i][k] + Matrix[l][j] and (k != j or i != l):
						ans = True
			if ans == False:
				noflag = True
				break
if not noflag:
	print('Yes')
else:
	print('No')


n = int(input())
mat = [list(map(int, input().split())) for i in range(n)]
c = []
for i in range(n):
	c.append(set())
	for j in range(n):
		c[i].add(mat[j][i])
ans = 'YES'
for i in range(n):
	for j in range(n):
		curr = mat[i][j]
		if curr == 1:
			continue
		for k in range(n):
			if curr - mat[i][k] in c[j]:
				break
		else:
			ans = 'NO'
			break
print(ans)


length = int(input())
grid = []
capteur = 1
for t in range(length):
	grid.append(input().split())
for j in range(length):
	for i in range(length):
		a = int(grid[i][j])
		if a != 1:
			capteur_solution = 0
			for n in range(length):
				for m in range(length):
					b = int(grid[i][n])
					c = int(grid[m][j])
					if a == b + c:
						capteur_solution = 1
						break
					else:
						capteur_solution = 0
				if capteur_solution == 1:
					break
			if capteur_solution == 0:
				capteur = 0
				break
		if capteur == 0:
			break
	if capteur == 0:
		break
if capteur == 0:
	print('No')
else:
	print('Yes')


n = int(input())
l = []
e = 0
for _ in range(n):
	g = list(map(int, input().split()))
	l.append(g)

def check(x, y):
	for k in range(n):
		if k != x:
			c = l[x][y] - l[k][y]
			if c in l[x]:
				return True
				break
	else:
		return False
for i in range(n):
	for j in range(n):
		if l[i][j] != 1:
			if not check(i, j):
				e += 1
				break
if e == 0:
	print('Yes')
else:
	print('No')


n = int(input())
arr = [list(map(int, input().split())) for _ in range(n)]
for i in range(n):
	for j in range(n):
		if arr[i][j] != 1:
			v = 0
			for k in range(n):
				for f in range(n):
					if arr[i][j] == arr[i][k] + arr[f][j]:
						v += 1
			if v == 0:
				print('No')
				exit(0)
print('Yes')


n = int(input())
a = []
for i in range(n):
	a.append(list(map(int, input().split())))
for i in range(n):
	for j in range(n):
		if a[i][j] != 1:
			tr = False
			for k in range(n):
				if a[i][j] - a[i][k] in [a[z][j] for z in range(n)]:
					tr = True
					break
			if not tr:
				print('No')
				exit()
print('Yes')


from sys import *
n = int(input())
l = [list(map(int, input().split())) for _ in range(n)]
for i in range(n):
	for j in range(n):
		if l[i][j] > 1:
			a = 0
			for ii in range(n):
				for jj in range(n):
					if l[i][jj] + l[ii][j] == l[i][j]:
						a += 1
						break
				if a:
					break
			else:
				print('No')
				exit()
print('Yes')


n = int(input())
a = []
for i in range(n):
	a.append([int(j) for j in input().split()])
for i in range(n):
	for j in range(n):
		if a[i][j] != 1:
			flag = False
			for k in range(n):
				for l in range(n):
					if a[i][l] + a[k][j] == a[i][j] and k != i and (l != j):
						flag = True
			if flag == False:
				print('No')
				exit(0)
print('Yes')