AtCoder Beginner Contest 088 - Takahashi's Information

We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left.

According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j.

Determine if he is correct.  

-----Constraints-----
 - c_{i, j} \ (1 \leq i \leq 3, 1 \leq j \leq 3) is an integer between 0 and 100 (inclusive).

-----Input-----
Input is given from Standard Input in the following format:
c_{1,1} c_{1,2} c_{1,3}
c_{2,1} c_{2,2} c_{2,3}
c_{3,1} c_{3,2} c_{3,3}

-----Output-----
If Takahashi's statement is correct, print Yes; otherwise, print No.

-----Sample Input-----
1 0 1
2 1 2
1 0 1

-----Sample Output-----
Yes

Takahashi is correct, since there are possible sets of integers such as: a_1=0,a_2=1,a_3=0,b_1=1,b_2=0,b_3=1.

Difficulty: EASY

Starter code:

Solutions:
c = []
for _ in [0] * 3:
	c += [list(map(int, input().split()))]
flag = True
for i in [0, 1]:
	for j in [0, 1]:
		if c[i][j] + c[i + 1][j + 1] != c[i + 1][j] + c[i][j + 1]:
			flag = False
print('Yes' if flag else 'No')


(c11, c12, c13) = map(int, input().split())
(c21, c22, c23) = map(int, input().split())
(c31, c32, c33) = map(int, input().split())
if c21 - c11 == c22 - c12 == c23 - c13 and c31 - c21 == c32 - c22 == c33 - c23:
	print('Yes')
else:
	print('No')


dif = []
for i in range(3):
	c_i = list(map(int, input().split()))
	dif.append([c_i[0] - c_i[1], c_i[1] - c_i[2]])
if dif[0] == dif[1] == dif[2]:
	print('Yes')
else:
	print('No')


c = [list(map(int, input().split())) for _ in range(3)]
A1 = c[1][0] - c[0][0]
A2 = c[2][0] - c[1][0]
B1 = c[0][1] - c[0][0]
B2 = c[0][2] - c[0][1]
if c[1][1] == A1 + B1 + c[0][0] and c[1][2] == A1 + B1 + B2 + c[0][0] and (c[2][1] == A1 + A2 + B1 + c[0][0]) and (c[2][2] == A1 + A2 + B1 + B2 + c[0][0]):
	print('Yes')
else:
	print('No')


A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
if (sum(A) + sum(B) + sum(C)) / 3 == A[0] + B[1] + C[2] == A[2] + B[1] + C[0]:
	print('Yes')
else:
	print('No')


c = []
for i in range(3):
	c.append(list(map(int, input().split())))
d = []
for i in range(3):
	d.append([c[i][0] - c[i][1], c[i][1] - c[i][2]])
if d[0] == d[1] == d[2]:
	print('Yes')
else:
	print('No')


c = [list(map(int, input().split())) for _ in range(3)]
ans = 'Yes'
for i in range(2):
	if c[0][i] - c[0][i + 1] == c[1][i] - c[1][i + 1] == c[2][i] - c[2][i + 1]:
		pass
	else:
		ans = 'No'
print(ans)


c = [list(map(int, input().split())) for _ in range(3)]
ok = True
lis = [[0, 1], [1, 2], [2, 0]]
d = [[c[l[0]][i] - c[l[1]][i] for i in range(3)] for l in lis]
e = [[c[i][l[0]] - c[i][l[1]] for i in range(3)] for l in lis]
for i in range(3):
	if d[i].count(d[i][0]) != 3:
		ok = False
	if e[i].count(e[i][0]) != 3:
		ok = False
if ok:
	print('Yes')
else:
	print('No')


c = [list(map(int, input().split())) for _ in range(3)]
for i in range(2):
	for j in range(2):
		if c[i][j] - c[i][j + 1] == c[i + 1][j] - c[i + 1][j + 1]:
			pass
		else:
			print('No')
			exit()
print('Yes')


c = [list(map(int, input().split())) for i in range(3)]
if all([c[i][j] - c[i][j + 1] == c[i + 1][j] - c[i + 1][j + 1] for i in range(2) for j in range(2)]):
	print('Yes')
else:
	print('No')


x = [[int(c) for c in input().split()] for _ in range(3)]
if 1 == len({r[0] - r[1] for r in x}) == len({r[0] - r[2] for r in x}):
	print('Yes')
else:
	print('No')


A = [[int(i) for i in input().split()] for i in range(3)]
if all((A[i][j] - A[i][j + 1] == A[i + 1][j] - A[i + 1][j + 1] for i in range(2) for j in range(2))):
	print('Yes')
else:
	print('No')


[(a, b, c), (d, e, f), (g, h, i)] = [map(int, input().split()) for i in range(3)]
if a - b == d - e == g - h and b - c == e - f == h - i:
	print('Yes')
else:
	print('No')


c = []
for i in range(3):
	c.append([int(j) for j in input().split(' ')])
if c[1][0] == c[0][0] + c[1][1] - c[0][1] and c[2][0] == c[0][0] + c[2][2] - c[0][2] and (c[2][1] == c[1][1] + c[2][2] - c[1][2]):
	print('Yes')
else:
	print('No')


l = [list(map(int, input().split())) for i in range(3)]
x = l[0][0]
y = l[0][1]
z = l[0][2]
a = 0
b = l[1][0] - x
c = l[2][0] - x
if b + y == l[1][1] and b + z == l[1][2] and (c + y == l[2][1]) and (c + z == l[2][2]):
	print('Yes')
else:
	print('No')


C = [list(map(int, input().split())) for _ in range(3)]
ans = 'Yes'
for i in range(1, 3):
	for j in range(1, 3):
		if C[i][j] + C[0][0] != C[i][0] + C[0][j]:
			ans = 'No'
print(ans)


cc = [list(map(int, input().split())) for i in range(3)]
tc = [x for c in cc for x in c]
if sum(tc) % 3 != 0:
	print('No')
else:
	cnt = 0
	for i in range(3):
		cnt += cc[i][i]
	if cnt == sum(tc) // 3:
		print('Yes')
	else:
		print('No')


(a, b, c) = map(int, input().split())
(d, e, f) = map(int, input().split())
(g, h, i) = map(int, input().split())
if a - b == d - e == g - h and b - c == e - f == h - i and (a - d == b - e == c - f) and (d - g == e - h == f - i):
	print('Yes')
else:
	print('No')


r1 = list(map(int, input().split()))
r2 = list(map(int, input().split()))
r3 = list(map(int, input().split()))
a = [0] * 3
b = [0] * 3
for i in range(101):
	a[0] = i
	for j in range(3):
		b[j] = r1[j] - a[0]
	a[1] = r2[0] - b[0]
	a[2] = r3[0] - b[0]
	flag = False
	for j in range(3):
		if r1[j] == a[0] + b[j] and r2[j] == a[1] + b[j] and (r3[j] == a[2] + b[j]):
			flag = True
		else:
			flag = False
			break
	if flag:
		break
print('Yes') if flag else print('No')


C = [[int(x) for x in input().split()] for _ in range(3)]
A = [0] * 3
B = [0] * 3
ans = False
for a1 in range(C[0][0] + 1):
	tmp = True
	b1 = C[0][0] - a1
	b2 = C[0][1] - a1
	b3 = C[0][2] - a1
	a2 = C[1][0] - b1
	a3 = C[2][0] - b1
	if C[1][1] != a2 + b2:
		tmp = False
	if C[1][2] != a2 + b3:
		tmp = False
	if C[2][1] != a3 + b2:
		tmp = False
	if C[2][2] != a3 + b3:
		tmp = False
	if tmp == True:
		ans = True
if ans:
	print('Yes')
else:
	print('No')


c = [list(map(int, input().split())) for _ in range(3)]
a = [0] * 3
b = [0] * 3
ok = True
b = c[0]
a[1] = c[1][0] - b[0]
a[2] = c[2][0] - b[0]
for i in range(3):
	for j in range(3):
		if c[i][j] != a[i] + b[j]:
			ok = False
if ok:
	print('Yes')
else:
	print('No')


c = [list(map(int, input().split())) for _ in range(3)]
if sum([sum(i) for i in c]) % 3 != 0:
	print('No')
else:
	a0 = 0
	(b0, b1, b2) = (c[0][0], c[0][1], c[0][2])
	(a1, a2) = (c[1][0] - b0, c[2][0] - b0)
	if c[1][1] == a1 + b1 and c[1][2] == a1 + b2 and (c[2][1] == a2 + b1) and (c[2][2] == a2 + b2):
		print('Yes')
	else:
		print('No')


C = [list(map(int, input().split())) for i in range(3)]
cii_sum = sum([C[i][i] for i in range(3)])
C_sum = sum(list(map(sum, C)))
print('Yes' if cii_sum == C_sum / 3 else 'No')


clst = list(map(int, input().split()))
dif = [x - clst[0] for x in clst]
clst = list(map(int, input().split()))
if not [clst[0] + x for x in dif] == clst:
	print('No')
	return
clst = list(map(int, input().split()))
if not [clst[0] + x for x in dif] == clst:
	print('No')
	return
print('Yes')


import itertools

def main():
	grid = [list(map(int, input().split())) for i in range(3)]
	all = sum(sum(grid, []))
	a = [0] * 3
	b = [0] * 3
	for (i, j, k) in itertools.product(list(range(grid[0][0] + 1)), list(range(grid[1][1] + 1)), list(range(grid[2][2] + 1))):
		a = [i, j, k]
		b = [grid[idx][idx] - v for (idx, v) in enumerate(a)]
		if sum(a) * 3 + sum(b) * 3 == all:
			print('Yes')
			return
	print('No')

def __starting_point():
	main()
__starting_point()


(*c,) = map(int, open(0).read().split())
print('YNeos'[sum(c) % 3 > 0 or sum(c) // 3 != c[0] + c[4] + c[8]::2])


c = [list(map(int, input().split())) for _ in range(3)]
a = [0] * 3
b = [0] * 3
for j in range(3):
	b[j] = c[0][j] - a[0]
for i in range(1, 3, 1):
	a[i] = c[i][0] - b[0]
for i in range(3):
	for j in range(3):
		if c[i][j] != a[i] + b[j]:
			print('No')
			return
print('Yes')


c = []
for i in range(3):
	c.append(list(map(int, input().split())))
ans = True
for i in range(2):
	tmp = c[0][i + 1] - c[0][i]
	for j in range(2):
		if c[j + 1][i + 1] - c[j + 1][i] != tmp:
			ans = False
			break
for i in range(2):
	tmp = c[i + 1][0] - c[i][0]
	for j in range(2):
		if c[i + 1][j + 1] - c[i][j + 1] != tmp:
			ans = False
			break
if ans:
	print('Yes')
else:
	print('No')


from fractions import gcd
from itertools import combinations, permutations, accumulate, product
from collections import deque, defaultdict, Counter
import decimal
import re
import math
import bisect
import sys
sys.setrecursionlimit(10000000)
mod = 10 ** 9 + 7
from sys import stdin
readline = stdin.readline

def readInts():
	return list(map(int, readline().split()))

def readTuples():
	return tuple(map(int, readline().split()))

def I():
	return int(readline())
C = [readInts() for _ in range(3)]
A = [0] * 3
B = [0] * 3
A[0] = 0
for i in range(3):
	B[i] = C[0][i]
for j in range(3):
	A[j] = C[j][0] - B[0]
for i in range(3):
	for j in range(3):
		if A[i] + B[j] == C[i][j]:
			pass
		else:
			print('No')
			return
print('Yes')


c = [list(map(int, input().split())) for i in range(3)]
for i in range(0, 2):
	if not c[0][0 + i] - c[0][1 + i] == c[1][0 + i] - c[1][1 + i] == c[2][0 + i] - c[2][1 + i]:
		print('No')
		break
	if not c[0 + i][0] - c[1 + i][0] == c[0 + i][1] - c[1 + i][1] == c[0 + i][2] - c[1 + i][2]:
		print('No')
		break
else:
	print('Yes')


(c1, c2, c3) = map(int, input().split())
(c4, c5, c6) = map(int, input().split())
(c7, c8, c9) = map(int, input().split())
if c1 - c2 == c4 - c5 == c7 - c8 and c3 - c2 == c6 - c5 == c9 - c8:
	print('Yes')
else:
	print('No')


c = []
for i in range(3):
	c.append([int(i) for i in input().split()])
(a1, a2, a3) = [0, c[1][1] - c[0][1], c[2][1] - c[0][1]]
(b1, b2, b3) = [c[0][0], c[0][1], c[0][2]]
ans = [[a1 + b1, a1 + b2, a1 + b3], [a2 + b1, a2 + b2, a2 + b3], [a3 + b1, a3 + b2, a3 + b3]]
if ans == c:
	print('Yes')
else:
	print('No')


c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))
sw = 1
b1 = min(c1)
a = [c1[0] - b1, c1[1] - b1, c1[2] - b1]
if not c2[0] - a[0] == c2[1] - a[1] == c2[2] - a[2]:
	sw = 0
if not c3[0] - a[0] == c3[1] - a[1] == c3[2] - a[2]:
	sw = 0
print(['No', 'Yes'][sw])


c = [list(map(int, input().split())) for _ in range(3)]
(b1, b2, b3) = (c[0][0], c[0][1], c[0][2])
if c[1][0] - b1 == c[1][1] - b2 == c[1][2] - b3 and c[2][0] - b1 == c[2][1] - b2 == c[2][2] - b3:
	print('Yes')
else:
	print('No')


def main():
	c1 = list(map(int, input().split()))
	c2 = list(map(int, input().split()))
	c3 = list(map(int, input().split()))
	for i in range(0, 101):
		for j in range(0, 101):
			for k in range(0, 101):
				flag = True
				b = []
				for l in range(3):
					b.append(c3[l] - k)
				for l in range(3):
					if j + b[l] != c2[l]:
						flag = False
						break
				for l in range(3):
					if i + b[l] != c1[l]:
						flag = False
						break
				if flag:
					print('Yes')
					return
	print('No')

def __starting_point():
	main()
__starting_point()


c = [tuple(map(int, input().split())) for i in range(3)]
if c[0][0] + c[1][1] + c[2][2] == c[0][1] + c[1][2] + c[2][0] and c[0][0] + c[1][1] + c[2][2] == c[0][2] + c[1][0] + c[2][1]:
	print('Yes')
else:
	print('No')


c = [list(map(int, input().split())) for i in range(3)]
for j in range(1, 3):
	if not c[0][0] - c[j][0] == c[0][1] - c[j][1] == c[0][2] - c[j][2]:
		print('No')
		exit()
print('Yes')


C = [[int(_) for _ in input().split()] for _ in range(3)]
D = [(C[_][1] - C[_][0], C[_][2] - C[_][0]) for _ in range(3)]
if D[0] == D[1] and D[0] == D[2]:
	print('Yes')
else:
	print('No')


x = [list(map(int, input().split())) for i in range(3)]
m = 0
for i in range(3):
	m += sum(x[i])
if m % 3 == 0 and (x[0][0] + x[1][1] + x[2][2]) * 3 == m:
	print('Yes')
else:
	print('No')


A = [list(map(int, input().split())) for i in range(3)]
if A[0][0] + A[1][1] == A[0][1] + A[1][0] and A[1][1] + A[2][2] == A[1][2] + A[2][1] and (A[0][0] + A[2][2] == A[0][2] + A[2][0]):
	print('Yes')
else:
	print('No')


A1 = 0
(B1, B2, B3) = map(int, input().split())
(C1, C2, C3) = map(int, input().split())
(D1, D2, D3) = map(int, input().split())
flag = 0
if not (C2 - B2 == C1 - B1 and C3 - B3 == C1 - B1 and (C2 - B2 == C3 - B3)):
	flag = 1
if not (D2 - B2 == D1 - B1 and D3 - B3 == D1 - B1 and (D2 - B2 == D3 - B3)):
	flag = 1
print('Yes' if flag == 0 else 'No')


m = lambda : map(int, input().split())
(a, b, c) = m()
(d, e, f) = m()
(g, h, i) = m()
print(['No', 'Yes'][d - a == e - b == f - c and g - a == h - b == i - c])


def main():
	c = [list(map(int, input().split())) for _ in [0, 0, 0]]
	for j in [2, 1, 0]:
		if c[j][0] - c[j - 1][0] == c[j][1] - c[j - 1][1] == c[j][2] - c[j - 1][2]:
			continue
		if c[0][j] - c[0][j - 1] == c[1][j] - c[1][j - 1] == c[2][j] - c[2][j - 1]:
			continue
		print('No')
		return
	print('Yes')
	return
main()


s = [list(map(int, input().split())) for i in range(3)]
t = []
for i in range(3):
	t.append([s[i][0] - s[i][1], s[i][0] - s[i][2]])
if t[0] == t[1] and t[0] == t[2]:
	print('Yes')
else:
	print('No')


C = [list(map(int, input().split())) for i in range(3)]
for n in range(0, 2):
	x = C[0][2] - C[0][n]
	y = C[1][2] - C[1][n]
	z = C[2][2] - C[2][n]
	if x != y or y != z:
		print('No')
		exit()
else:
	print('Yes')


X = []
for i in range(3):
	x = list(map(int, input().split()))
	X.append([x[0] - x[1], x[1] - x[2]])
if X[0] == X[1] and X[1] == X[2]:
	print('Yes')
else:
	print('No')


grid = [[-1] * 4 for i in range(4)]
for i in range(1, 4):
	(grid[i][1], grid[i][2], grid[i][3]) = list(map(int, input().split()))
	grid[i][0] = min(grid[i][1], grid[i][2], grid[i][3])
isOK = False
for i in range(grid[1][0] + 1):
	grid[0][0] = i
	grid[0][1] = grid[1][1] - i
	grid[0][2] = grid[1][2] - i
	grid[0][3] = grid[1][3] - i
	if grid[2][1] - grid[0][1] == grid[2][2] - grid[0][2] and grid[2][2] - grid[0][2] == grid[2][3] - grid[0][3]:
		if grid[3][1] - grid[0][1] == grid[3][2] - grid[0][2] and grid[3][2] - grid[0][2] == grid[3][3] - grid[0][3]:
			isOK = True
			break
if isOK:
	print('Yes')
else:
	print('No')


A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
if A[0] - A[1] == B[0] - B[1] == C[0] - C[1] and A[1] - A[2] == B[1] - B[2] == C[1] - C[2]:
	print('Yes')
else:
	print('No')


c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))
if sum(c1) + sum(c2) + sum(c3) == 3 * (c1[0] + c2[1] + c3[2]):
	print('Yes')
else:
	print('No')


c = [list(map(int, input().split())) for i in range(3)]
if 1 == len({r[0] - r[1] for r in c}) == len({r[1] - r[2] for r in c}):
	print('Yes')
else:
	print('No')


mat = [list(map(int, input().split())) for _ in range(3)]
checks = [[0, 1], [0, 2], [1, 2]]
for (i, j) in checks:
	if mat[i][i] + mat[j][j] != mat[i][j] + mat[j][i]:
		print('No')
		exit()
print('Yes')


(c11, c12, c13) = list(map(int, input().split()))
(c21, c22, c23) = list(map(int, input().split()))
(c31, c32, c33) = list(map(int, input().split()))
ans = 'No'
for a1 in range(c11 + 1):
	b1 = c11 - a1
	b2 = c12 - a1
	b3 = c13 - a1
	a2 = c21 - b1
	a3 = c31 - b1
	if c22 == a2 + b2 and c23 == a2 + b3 and (c32 == a3 + b2) and (c33 == a3 + b3):
		ans = 'Yes'
		break
print(ans)


c = [list(map(int, input().split())) for _ in range(3)]
for i in range(1, 3):
	d = c[i][0] - c[0][0]
	e = c[0][i] - c[0][0]
	for j in range(1, 3):
		if d != c[i][j] - c[0][j]:
			print('No')
			return
		if e != c[j][i] - c[j][0]:
			print('No')
			return
print('Yes')


c = [list(map(int, input().split())) for _ in range(3)]
f = True
for j in range(2):
	x = c[j][0] - c[j + 1][0]
	y = c[0][j] - c[0][j + 1]
	for i in range(3):
		if c[j][i] - c[j + 1][i] != x:
			f = False
		if c[i][j] - c[i][j + 1] != y:
			f = False
print(['No', 'Yes'][int(f)])


C = []
for _ in range(3):
	a = list(map(int, input().split()))
	b = min(a)
	for i in range(3):
		a[i] -= b
	C.append(a)
if C[0] == C[1] == C[2]:
	print('Yes')
else:
	print('No')


c = [list(map(int, input().split())) for _ in range(3)]
flag = True
for i in range(1, 3):
	if not c[i][0] - c[0][0] == c[i][1] - c[0][1] == c[i][2] - c[0][2]:
		flag = False
	if not c[0][i] - c[0][0] == c[1][i] - c[1][0] == c[2][i] - c[2][0]:
		flag = False
if flag:
	print('Yes')
else:
	print('No')


a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a = (a[1] - a[0], a[2] - a[0])
b = (b[1] - b[0], b[2] - b[0])
c = (c[1] - c[0], c[2] - c[0])
if a == b and b == c:
	print('Yes')
else:
	print('No')


import numpy as np
M = np.array(list(map(int, open(0).read().split()))).reshape(3, 3)
hSum = M.sum(axis=0)
vSum = M.sum(axis=1)
f = True
for i in range(3):
	if (hSum[i] - hSum[(i + 1) % 3]) % 3 != 0:
		f = False
for i in range(3):
	if (vSum[i] - vSum[(i + 1) % 3]) % 3 != 0:
		f = False
print('Yes' if f else 'No')


def main():
	ans = 'No'
	c = [list(map(int, input().split())) for _ in range(3)]
	for i in range(101):
		for j in range(101):
			for k in range(101):
				flgs = [False, False, False]
				if c[0][0] - i == c[1][0] - j and c[0][0] - i == c[2][0] - k:
					flgs[0] = True
				if c[0][1] - i == c[1][1] - j and c[0][1] - i == c[2][1] - k:
					flgs[1] = True
				if c[0][2] - i == c[1][2] - j and c[0][2] - i == c[2][2] - k:
					flgs[2] = True
				if all(flgs):
					ans = 'Yes'
	print(ans)

def __starting_point():
	main()
__starting_point()


ans = 'Yes'
c = []
for _ in range(3):
	c.append(list(map(int, input().split())))
adiff = []
bdiff = []
for i in range(2):
	adiff.append(c[i + 1][0] - c[i][0])
	bdiff.append(c[0][i + 1] - c[0][i])
for i in range(1, 3):
	for j in range(1, 3):
		if adiff[i - 1] != c[i][j] - c[i - 1][j] or bdiff[j - 1] != c[i][j] - c[i][j - 1]:
			ans = 'No'
			break
print(ans)


C = [list(map(int, input().split())) for _ in range(3)]
x = [0, 0, 0]
y = [0, 0, 0]
for i in range(3):
	y[i] = C[0][i]
for i in range(3):
	x[i] = C[i][0] - y[0]
for i in range(3):
	for j in range(3):
		if C[i][j] != x[i] + y[j]:
			print('No')
			return
print('Yes')


c = [list(map(int, input().split())) for _ in range(3)]
check = False
for i in range(101):
	for j in range(101):
		for k in range(101):
			o = c[0][0] - i
			p = c[1][1] - j
			q = c[2][2] - k
			if o < 0 or p < 0 or q < 0:
				continue
			ls = [[i + o, i + p, i + q], [j + o, j + p, j + q], [k + o, k + p, k + q]]
			if ls == c:
				check = True
				break
print('Yes' if check else 'No')


C = list((list(map(int, input().split())) for _ in range(3)))
a = C[0][0] + C[1][1] + C[2][2]
b = C[0][2] + C[1][0] + C[2][1]
c = C[0][1] + C[1][2] + C[2][0]
if a == b == c:
	print('Yes')
else:
	print('No')


c = [0] * 3
for i in range(3):
	c[i] = list(map(int, input().split()))
sum_mat = (sum(c[0]) + sum(c[1]) + sum(c[2])) / 3
print('Yes' if sum_mat == c[0][0] + c[1][1] + c[2][2] else 'No')


c = [list(map(int, input().split())) for _ in range(3)]
s = 0
for i in range(3):
	for j in range(3):
		s += c[i][j]
if 3 * (c[0][0] + c[1][1] + c[2][2]) == s:
	print('Yes')
else:
	print('No')


c = [list(map(int, input().split())) for _ in range(3)]
flg = all((c[0][i + 1] - c[0][i] == c[1][i + 1] - c[1][i] == c[2][i + 1] - c[2][i] for i in range(2)))
print(['No', 'Yes'][flg])


import numpy as np

def check(a, b, c):
	flag = True
	for i in range(3):
		for j in range(3):
			if c[i][j] != a[i] + b[j]:
				flag = False
				return flag
	return flag
c = []
c.append(list(map(int, input().split())))
c.append(list(map(int, input().split())))
c.append(list(map(int, input().split())))
arr_c = np.array(c)
a_max = np.amax(arr_c, axis=1)
b_max = np.amax(arr_c, axis=0)
a = []
b = []
for i in range(3):
	if len(list(range(0, a_max[i] + 1, 1))) == 0:
		a.append([0])
	else:
		a.append(list(range(0, a_max[i] + 1, 1)))
	if len(list(range(0, b_max[i] + 1, 1))) == 0:
		b.append([0])
	else:
		b.append(list(range(0, b_max[i] + 1, 1)))
ans = 'No'
cnt = 0
for a0 in a[0]:
	for b0 in b[0]:
		if c[0][0] != a0 + b0:
			continue
		for a1 in a[1]:
			if c[1][0] != a1 + b0:
				continue
			for b1 in b[1]:
				if c[0][1] != a0 + b1 or c[1][1] != a1 + b1:
					continue
				for a2 in a[2]:
					if c[2][0] != a2 + b0 or c[2][1] != a2 + b1:
						continue
					for b2 in b[2]:
						if c[0][2] != a0 + b2 or c[1][2] != a1 + b2 or c[2][2] != a2 + b2:
							continue
						print('Yes')
						return
print(ans)


L = [list(map(int, input().split())) for _ in range(3)]
T = sum([sum(i) for i in L])
print('Yes' if L[0][0] + L[1][1] + L[2][2] == T / 3 else 'No')


(*m,) = map(int, open(0).read().split())
b = m[:3]
a = [0, m[3] - b[0], m[6] - b[0]]
for i in range(9):
	if m[i] != a[i // 3] + b[i % 3]:
		print('No')
		exit()
print('Yes')


C = [tuple(map(int, input().split())) for _ in range(3)]
print('YNeos'[not all((C[i][j] + C[(i + 1) % 3][(j + 1) % 3] == C[(i + 1) % 3][j] + C[i][(j + 1) % 3] for i in range(3) for j in range(3)))::2])


c = []
for i in range(3):
	c.append(list(map(int, input().split())))
for i in range(2):
	if c[0][i] - c[0][i + 1] != c[1][i] - c[1][i + 1] or c[1][i] - c[1][i + 1] != c[2][i] - c[2][i + 1]:
		print('No')
		exit()
print('Yes')


c = list(map(int, open(0).read().split()))
a = all([c[i] - c[i + 1] == c[i + 3] - c[i + 4] for i in [0, 1, 3, 4]])
b = all([c[i] - c[i + 3] == c[i + 1] - c[i + 4] for i in [0, 1, 3, 4]])
if a and b:
	print('Yes')
else:
	print('No')


N = [list(map(int, input().split())) for _ in range(3)]
if N[0][0] + N[1][1] + N[2][2] == N[0][1] + N[1][2] + N[2][0] == N[0][2] + N[1][0] + N[2][1]:
	print('Yes')
else:
	print('No')


import numpy as np
l = [list(map(int, input().split())) for i in range(3)]
l_2 = np.array(l).T

def square(l):
	flag = 1
	for i in range(2):
		for j in range(2):
			if l[j][i] - l[j + 1][i] != l[j][i + 1] - l[j + 1][i + 1]:
				flag = 0
	return flag
if square(l) * square(l_2) == 1:
	print('Yes')
else:
	print('No')


c = [list(map(int, input().split())) for _ in range(3)]
x = c[1][0] - c[0][0]
y = c[2][0] - c[0][0]
for i in range(3):
	c[1][i] -= x
	c[2][i] -= y
if c[0] == c[1] == c[2]:
	print('Yes')
else:
	print('No')


c = [[int(x) for x in input().split()] for _ in range(3)]
ans = False
for a1 in range(101):
	for a2 in range(101):
		for a3 in range(101):
			ok = True
			b1 = c[0][0] - a1
			b2 = c[0][1] - a1
			b3 = c[0][2] - a1
			if c[1][0] != a2 + b1 or c[1][1] != a2 + b2 or c[1][2] != a2 + b3 or (c[2][0] != a3 + b1) or (c[2][1] != a3 + b2) or (c[2][2] != a3 + b3):
				ok = False
			if ok:
				ans = True
if ans:
	print('Yes')
else:
	print('No')


C = [list(map(int, input().split())) for _ in range(3)]
x = C[1][0] - C[0][0] == C[1][1] - C[0][1] == C[1][2] - C[0][2]
y = C[2][0] - C[0][0] == C[2][1] - C[0][1] == C[2][2] - C[0][2]
if x and y:
	print('Yes')
else:
	print('No')


(s1, s2, s3) = map(int, input().split())
(s4, s5, s6) = map(int, input().split())
(s7, s8, s9) = map(int, input().split())
if s1 - s4 == s2 - s5 == s3 - s6 and s4 - s7 == s5 - s8 == s6 - s9:
	print('Yes')
else:
	print('No')


grid = []
al = 0
cnt = 0
for i in range(3):
	a = list(map(int, input().split()))
	al += sum(a)
	cnt += a[i]
	grid.append(a)
if al == cnt * 3:
	print('Yes')
else:
	print('No')


c = [tuple(map(int, input().split())) for _ in range(3)]
for i in range(2):
	for j in range(2):
		if c[i][j] - c[i + 1][j] != c[i][j + 1] - c[i + 1][j + 1]:
			print('No')
			exit()
print('Yes')


c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))
f = 0
for a1 in range(min(c1) + 1):
	b1 = c1[0] - a1
	b2 = c1[1] - a1
	b3 = c1[2] - a1
	a2_1 = c2[0] - b1
	a2_2 = c2[1] - b2
	a2_3 = c2[2] - b3
	if not (a2_1 == a2_2 and a2_2 == a2_3):
		continue
	a3_1 = c3[0] - b1
	a3_2 = c3[1] - b2
	a3_3 = c3[2] - b3
	if not (a3_1 == a3_2 and a3_2 == a3_3):
		continue
	print('Yes')
	f = 1
	break
if not f:
	print('No')


C = [list(map(int, input().split())) for _ in range(3)]
for i in range(2):
	for j in range(2):
		if C[i][j] + C[i + 1][j + 1] != C[i][j + 1] + C[i + 1][j]:
			print('No')
			exit()
print('Yes')


cs = [list(map(int, input().split())) for _ in range(3)]
a = [i - j for (i, j) in zip(cs[0], cs[1])]
b = [i - j for (i, j) in zip(cs[1], cs[2])]
print('Yes' if a[0] == a[1] == a[2] and b[0] == b[1] == b[2] else 'No')


J = lambda : map(int, input().split())
(A, B, C) = J()
(D, E, F) = J()
(G, H, I) = J()
print('YNeos'[any([A - B - D + E, A - C - G + I, E - F - H + I])::2])


C1 = list(map(int, input().split()))
C2 = list(map(int, input().split()))
C3 = list(map(int, input().split()))
k2 = C2[0] - C1[0]
k3 = C3[0] - C1[0]
C2 = [i - k2 for i in C2]
C3 = [i - k3 for i in C3]
print(['No', 'Yes'][C1 == C2 == C3])


List = []
for i in range(3):
	List.append(list(map(int, input().split())))
a = 0
b = 0
c = 0
flg = True
for i in range(2):
	a = List[0][i + 1] - List[0][i]
	b = List[1][i + 1] - List[1][i]
	c = List[2][i + 1] - List[2][i]
	if a != b or b != c or c != a:
		flg = False
	a = List[i + 1][0] - List[i][0]
	b = List[i + 1][1] - List[i][1]
	c = List[i + 1][2] - List[i][2]
	if a != b or b != c or c != a:
		flg = False
if flg:
	print('Yes')
else:
	print('No')


import sys
c = [list(map(int, input().split())) for i in range(3)]
if not c[0][0] - c[0][1] == c[1][0] - c[1][1] == c[2][0] - c[2][1]:
	print('No')
	return
if not c[0][0] - c[0][2] == c[1][0] - c[1][2] == c[2][0] - c[2][2]:
	print('No')
	return
if not c[0][1] - c[0][2] == c[1][1] - c[1][2] == c[2][1] - c[2][2]:
	print('No')
	return
if not c[0][0] - c[1][0] == c[0][1] - c[1][1] == c[0][2] - c[1][2]:
	print('No')
	return
if not c[0][0] - c[2][0] == c[0][1] - c[2][1] == c[0][2] - c[2][2]:
	print('No')
	return
if not c[1][0] - c[2][0] == c[1][1] - c[2][1] == c[1][2] - c[2][2]:
	print('No')
	return
print('Yes')


xy = [list(map(int, input().split())) for i in range(3)]
result = sum(map(sum, xy))
if result % 3 != 0:
	print('No')
	return
if result != (xy[0][0] + xy[1][1] + xy[2][2]) * 3:
	print('No')
	return
if result != (xy[0][2] + xy[1][1] + xy[2][0]) * 3:
	print('No')
	return
else:
	print('Yes')


c = [list(map(int, input().split())) for k in range(3)]
if c[0][0] + c[1][1] != c[0][1] + c[1][0] or c[0][2] + c[2][0] != c[0][0] + c[2][2] or c[1][2] + c[2][1] != c[1][1] + c[2][2]:
	print('No')
else:
	print('Yes')


c = [list(map(int, input().split())) for i in range(3)]
a = []
b = []
for i in range(3):
	a.append(c[i][0] - c[i][1])
	b.append(c[i][0] - c[i][2])
if len(set(a)) == 1 and len(set(b)) == 1:
	print('Yes')
else:
	print('No')


c = [tuple(map(int, input().split())) for _ in range(3)]
Accepted = {(c[0][0] + k, c[0][1] + k, c[0][2] + k) for k in range(-100, 101)}
print('Yes' if c[1] in Accepted and c[2] in Accepted else 'No')


C = [list(map(int, input().split())) for i in range(3)]
(a2, a3) = ([], [])
for i in range(3):
	a2.append(C[0][i] - C[1][i])
	a3.append(C[0][i] - C[2][i])
if len(set(a2)) == 1 and len(set(a3)) == 1:
	print('Yes')
else:
	print('No')


a = [list(map(int, input().split())) for _ in range(3)]
b = list(zip(*a))
c = a[0]
d = b[0]
f = True
dx1 = c[1] - c[0]
dx2 = c[2] - c[1]
dy1 = d[1] - d[0]
dy2 = d[2] - d[1]
for i in range(3):
	c = a[i]
	d = b[i]
	if dx1 == c[1] - c[0] and dx2 == c[2] - c[1] and (dy1 == d[1] - d[0]) and (dy2 == d[2] - d[1]):
		f = True
	else:
		f = False
		break
if f:
	print('Yes')
else:
	print('No')


(a, b, c) = [int(v) for v in input().split()]
(d, e, f) = [int(v) for v in input().split()]
(g, h, i) = [int(v) for v in input().split()]
if a + e + i == d + h + c and a + e + i == b + f + g:
	print('Yes')
else:
	print('No')


def LIHW(h):
	return [list(map(int, input().split())) for _ in range(h)]
masu = LIHW(3)
ans = 'Yes'
for i in range(2):
	if masu[i + 1][1] - masu[i + 1][0] != masu[0][1] - masu[0][0]:
		ans = 'No'
	if masu[i + 1][2] - masu[i + 1][1] != masu[0][2] - masu[0][1]:
		ans = 'No'
for i in range(2):
	if masu[1][i + 1] - masu[0][i + 1] != masu[1][0] - masu[0][0]:
		ans = 'No'
	if masu[2][i + 1] - masu[1][i + 1] != masu[2][0] - masu[1][0]:
		ans = 'No'
print(ans)


c = [list(map(int, input().split())) for i in range(3)]
x = c[0][2] - c[0][1]
y = c[0][1] - c[0][0]
ans = 'Yes'
for i in range(1, 3):
	if c[i][2] - c[i][1] != x or c[i][1] - c[i][0] != y:
		ans = 'No'
		break
print(ans)


l = [list(map(int, input().split())) for i in range(3)]
ans = 0
for i in l:
	ans += sum(i)
print('Yes' if ans / 3 == l[0][0] + l[1][1] + l[2][2] else 'No')


CC = []
for i in range(3):
	C = list(map(int, input().split()))
	C = list(map(lambda x: str(x - min(C)), C))
	CC.append(' '.join(C))
if len(set(CC)) > 1:
	print('No')
else:
	print('Yes')


a = [list(map(int, input().split())) for i in range(3)]
s = a[0] + a[1] + a[2]

def f(i):
	return s[i] + s[i + 2] - s[i - 1] - s[i + 3]
if f(1) == f(2) == f(4) == f(5) == 0:
	print('Yes')
else:
	print('No')


import io
array = []
for i in range(3):
	array.append(list(map(int, input().split())))
if (array[0][0] + array[1][1] + array[2][2]) * 3 == sum(array[0]) + sum(array[1]) + sum(array[2]):
	print('Yes')
else:
	print('No')


a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
print('Yes' if a[0] - b[0] == a[1] - b[1] == a[2] - b[2] and a[0] - c[0] == a[1] - c[1] == a[2] - c[2] else 'No')


c = [list(map(int, input().split())) for i in range(3)]
ans = 'Yes'
for i in range(3):
	for j in range(3):
		if c[i][j] == c[i - 1][j] + c[i][j - 1] - c[i - 1][j - 1]:
			continue
		ans = 'No'
print(ans)


ls = []
for i in range(3):
	ls.append(list(map(int, input().split())))
ans = 'Yes'
if ls[1][1] - ls[1][0] != ls[0][1] - ls[0][0]:
	ans = 'No'
if ls[2][1] - ls[2][0] != ls[0][1] - ls[0][0]:
	ans = 'No'
if ls[1][2] - ls[1][0] != ls[0][2] - ls[0][0]:
	ans = 'No'
if ls[2][2] - ls[2][0] != ls[0][2] - ls[0][0]:
	ans = 'No'
print(ans)


from sys import stdin, stdout

def solve():
	c1 = list(map(int, input().split()))
	c2 = list(map(int, input().split()))
	c3 = list(map(int, input().split()))
	b = c1
	a2 = [c2[i] - b[i] for i in range(3)]
	a3 = [c3[i] - b[i] for i in range(3)]
	if max(a2) == min(a2) and max(a3) == min(a3):
		print('Yes')
	else:
		print('No')

def main():
	solve()

def __starting_point():
	main()
__starting_point()


grid = [list(map(int, input().split())) for _ in range(3)]
for i in range(3):
	c = grid[i][0]
	for j in range(3):
		grid[i][j] -= c
ans = 'Yes' if grid[0] == grid[1] and grid[1] == grid[2] else 'No'
print(ans)


(c1, c2, c3) = map(int, input().split())
d1 = c2 - c1
d2 = c3 - c2
ans = 0
for i in range(2):
	(c1, c2, c3) = map(int, input().split())
	if c2 - c1 != d1 or c3 - c2 != d2:
		ans += 1
print('Yes' if ans == 0 else 'No')


c = []
for _ in range(3):
	c.append(list(map(int, input().split())))
if c[0][1] - c[0][0] == c[1][1] - c[1][0] and c[2][1] - c[2][0] == c[1][1] - c[1][0] and (c[0][2] - c[0][1] == c[1][2] - c[1][1]) and (c[2][2] - c[2][1] == c[1][2] - c[1][1]):
	print('Yes')
else:
	print('No')


L = [list(map(int, input().split())) for _ in range(3)]
c1 = L[0][2] + L[1][1] + L[2][0]
c2 = L[0][1] + L[1][0] + L[2][2]
c3 = L[0][0] + L[1][2] + L[2][1]
if c1 == c2 and c2 == c3:
	print('Yes')
else:
	print('No')


a = []
for i in range(3):
	a.append(list(map(int, input().split())))
sa1 = a[0][0] - a[1][0]
sa2 = a[0][0] - a[2][0]
if sum(a[0]) == sum(a[1]) + 3 * sa1 == sum(a[2]) + 3 * sa2:
	print('Yes')
else:
	print('No')


C = [list(map(int, input().split())) for _ in range(3)]
if not C[0][0] - C[0][1] == C[1][0] - C[1][1] == C[2][0] - C[2][1]:
	print('No')
	return
if not C[0][0] - C[0][2] == C[1][0] - C[1][2] == C[2][0] - C[2][2]:
	print('No')
	return
if not C[0][2] - C[0][1] == C[1][2] - C[1][1] == C[2][2] - C[2][1]:
	print('No')
	return
print('Yes')


C = [list(map(int, input().split())) for _ in range(3)]
if sum((sum(row) for row in C)) == 3 * sum((C[i][i] for i in range(3))):
	print('Yes')
else:
	print('No')


C = [list(map(int, input().split())) for i in range(3)]
B = [C[0][0], C[0][1], C[0][2]]
A = [0, C[1][0] - B[0], C[2][0] - B[0]]
for i in range(3):
	for j in range(3):
		if C[i][j] != A[i] + B[j]:
			print('No')
			quit()
print('Yes')


a = []
a.append(list(map(int, input().split())))
a.append(list(map(int, input().split())))
a.append(list(map(int, input().split())))
if not a[0][2] - a[0][1] == a[1][2] - a[1][1] == a[2][2] - a[2][1]:
	print('No')
	return
if not a[0][1] - a[0][0] == a[1][1] - a[1][0] == a[2][1] - a[2][0]:
	print('No')
	return
if not a[0][0] - a[1][0] == a[0][1] - a[1][1] == a[0][2] - a[1][2]:
	print('No')
	return
if not a[2][0] - a[1][0] == a[2][1] - a[1][1] == a[2][2] - a[1][2]:
	print('No')
	return
print('Yes')


C1 = list(map(int, input().split()))
C2 = list(map(int, input().split()))
C3 = list(map(int, input().split()))
if C1[0] - C1[1] == C2[0] - C2[1] == C3[0] - C3[1] and C1[1] - C1[2] == C2[1] - C2[2] == C3[1] - C3[2] and (C1[0] - C2[0] == C1[1] - C2[1] == C1[2] - C2[2]) and (C2[0] - C3[0] == C2[1] - C3[1] == C2[2] - C3[2]):
	print('Yes')
else:
	print('No')


c = [list(map(int, input().split())) for _ in range(3)]
c1 = [c[i][i] for i in range(3)]
c2 = [sum(i) for i in c]
print('Yes' if sum(c1) * 3 == sum(c2) else 'No')


l = [list(map(int, input().split())) for _ in range(3)]
flag = 'No'
if l[0][1] - l[0][0] == l[1][1] - l[1][0] == l[2][1] - l[2][0]:
	if l[0][2] - l[0][1] == l[1][2] - l[1][1] == l[2][2] - l[2][1]:
		flag = 'Yes'
print(flag)


prev = list(map(int, input().split()))
flag = True
for _ in range(2):
	cur = list(map(int, input().split()))
	if not cur[0] - prev[0] == cur[1] - prev[1] == cur[2] - prev[2]:
		flag = False
print('Yes' if flag else 'No')


C = [list(map(int, input().split())) for i in range(3)]
Bs = [C[0][i] for i in range(3)]
As = [0, C[1][0] - Bs[0], C[2][0] - Bs[0]]
if all((As[i] + Bs[j] == C[i][j] for i in range(3) for j in range(3))):
	print('Yes')
else:
	print('No')


a = [list(map(int, input().split())) for i in range(3)]
for i in range(2):
	for j in range(2):
		if a[i][j] - a[i][j + 1] == a[i + 1][j] - a[i + 1][j + 1]:
			continue
		else:
			print('No')
			exit()
print('Yes')


(*l,) = map(int, open(0).read().split())
print('YNeos'[4 != sum((sum((l[j] - l[0] + l[i] == l[i + j] for i in [1, 2])) for j in [3, 6]))::2])


c_0 = list(map(int, input().split()))
c_1 = list(map(int, input().split()))
c_2 = list(map(int, input().split()))
d = c_0[0] + c_1[1] + c_2[2]
e = c_1[0] + c_0[2] + c_2[1]
f = c_0[1] + c_1[2] + c_2[0]
if d == e == f:
	print('Yes')
else:
	print('No')


c = []
for i in range(3):
	c.append([int(x) for x in input().split()])
res = 'No'
for i in range(101):
	for j in range(101):
		for k in range(101):
			if c[0][0] - i == c[1][0] - j == c[2][0] - k:
				if c[0][1] - i == c[1][1] - j == c[2][1] - k:
					if c[0][2] - i == c[1][2] - j == c[2][2] - k:
						res = 'Yes'
print(res)


c_1 = list(map(int, input().split()))
c_2 = list(map(int, input().split()))
c_3 = list(map(int, input().split()))
c = c_1 + c_2 + c_3
if sum(c) == 3 * (c_1[0] + c_2[1] + c_3[2]):
	print('Yes')
else:
	print('No')


R = []
for i in range(3):
	(c1, c2, c3) = map(int, input().split())
	R.append([c1 - c2, c1 - c3])
print('Yes' if R[0] == R[1] == R[2] else 'No')


a = list(map(int, open(0).read().split()))
print('Yes' if a[0] - a[1] == a[3] - a[4] == a[6] - a[7] and a[1] - a[2] == a[4] - a[5] == a[7] - a[8] and (a[0] - a[3] == a[1] - a[4] == a[2] - a[5]) and (a[3] - a[6] == a[4] - a[7] == a[5] - a[8]) else 'No')


import sys
YES = 'Yes'
NO = 'No'

def solve(c: 'List[List[int]]'):
	from itertools import product
	for (a1, b1) in product(list(range(101)), repeat=2):
		a2 = c[1][0] - b1
		a3 = c[2][0] - b1
		b2 = c[0][1] - a1
		b3 = c[0][2] - a1
		if a2 < 0 or a3 < 0 or b2 < 0 or (b3 < 0):
			continue
		a = [a1, a2, a3]
		b = [b1, b2, b3]
		if all((a[i] + b[j] == c[i][j] for (i, j) in product(list(range(3)), repeat=2))):
			return YES
	return NO

def main():

	def iterate_tokens():
		for line in sys.stdin:
			for word in line.split():
				yield word
	tokens = iterate_tokens()
	c = [[int(next(tokens)) for _ in range(3)] for _ in range(3)]
	print(solve(c))

def test():
	import doctest
	doctest.testmod()

def __starting_point():
	main()
__starting_point()


c = [list(map(int, input().split())) for i in range(3)]
for i in range(2):
	if c[i][0] - c[i + 1][0] == c[i][1] - c[i + 1][1] and c[i][2] - c[i + 1][2] == c[i][1] - c[i + 1][1]:
		continue
	else:
		print('No')
		exit()
print('Yes')


(c_1_1, c_1_2, c_1_3) = map(int, input().split())
(c_2_1, c_2_2, c_2_3) = map(int, input().split())
(c_3_1, c_3_2, c_3_3) = map(int, input().split())
ans = 'No'
for a_1 in range(101):
	b_1 = c_1_1 - a_1
	b_2 = c_1_2 - a_1
	b_3 = c_1_3 - a_1
	for a_2 in range(101):
		if c_2_1 != a_2 + b_1:
			continue
		if c_2_2 != a_2 + b_2:
			continue
		if c_2_3 != a_2 + b_3:
			continue
		for a_3 in range(101):
			if c_3_1 != a_3 + b_1:
				continue
			if c_3_2 != a_3 + b_2:
				continue
			if c_3_3 != a_3 + b_3:
				continue
			ans = 'Yes'
			break
		if ans == 'Yes':
			break
	if ans == 'Yes':
		break
print(ans)


(a, b, c) = map(int, input().split())
s = 'Yes'
for _ in [0] * 2:
	(x, y, z) = map(int, input().split())
	if not x - a == y - b == z - c:
		s = 'No'
print(s)


c = [list(map(int, input().split())) for _ in range(3)]
d = set()
e = set()
for i in range(3):
	d.add(c[i][0] - c[i][1])
	e.add(c[i][1] - c[i][2])
print('Yes' if len(d) == len(e) == 1 else 'No')


c = [list(map(int, input().split())) for i in range(3)]
a1 = 0
(b1, b2, b3) = (c[0][0], c[0][1], c[0][2])
a2 = c[1][0] - b1
a3 = c[2][0] - b1
check = []
check.append(c[1][1] == a2 + b2)
check.append(c[2][1] == a3 + b2)
check.append(c[1][2] == a2 + b3)
check.append(c[2][2] == a3 + b3)
if sum(check) == 4:
	print('Yes')
else:
	print('No')


(a, b, c) = map(int, input().split())
(d, e, f) = map(int, input().split())
(g, h, i) = map(int, input().split())
x = a + e == b + d and b + f == c + e and (d + h == e + g) and (e + i == f + h)
print('YNeos'[0 if x else 1::2])


c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))
if c1[1] - c1[0] == c2[1] - c2[0] == c3[1] - c3[0] and c1[2] - c1[1] == c2[2] - c2[1] == c3[2] - c3[1]:
	print('Yes')
else:
	print('No')


c = [list(map(int, input().split())) for _ in range(3)]
for i in [1, 2]:
	d1 = c[0][0] - c[i][0]
	d2 = c[0][1] - c[i][1]
	d3 = c[0][2] - c[i][2]
	d4 = c[0][0] - c[0][i]
	d5 = c[1][0] - c[1][i]
	d6 = c[2][0] - c[2][i]
	if d1 != d2 or d1 != d3 or d4 != d5 or (d4 != d6):
		print('No')
		return
print('Yes')


r = [None] * 3
for i in range(3):
	x = list(map(int, input().split()))
	r[i] = [x[i] - x[i + 1] for i in range(2)]
print('Yes' if all((r[i] == r[i + 1] for i in range(2))) else 'No')


c = [list(map(int, input().split())) for _ in range(3)]
b = [i[0] for i in c]
if len(set([i - j[1] for (i, j) in zip(b, c)])) == 1 and len(set([i - j[2] for (i, j) in zip(b, c)])) == 1:
	print('Yes')
else:
	print('No')


c = [list(map(int, input().split())) for i in range(3)]
for i in range(3):
	c[i] = [j - min(c[i]) for j in c[i]]
if c[0] == c[1] and c[1] == c[2]:
	print('Yes')
else:
	print('No')


ar = [[int(i) for i in input().split()] for j in range(3)]
if ar[0][0] + ar[1][1] + ar[2][2] == ar[0][1] + ar[1][2] + ar[2][0] == ar[0][2] + ar[1][0] + ar[2][1]:
	print('Yes')
else:
	print('No')


l = [[int(i) for i in input().split()] for x in range(3)]
total1 = 0
total2 = 0
for i in range(3):
	total1 += sum(l[i])
	total2 += l[i][i]
if total1 == total2 * 3:
	print('Yes')
else:
	print('No')


List = [list(map(int, input().split())) for i in range(3)]
newlist = []
new = [x - y for (x, y) in zip(List[0], List[1])]
new2 = [x - y for (x, y) in zip(List[2], List[1])]
if new[0] == new[1] and new[1] == new[2]:
	pass
else:
	print('No')
	return
if new2[0] == new2[1] and new2[1] == new2[2]:
	pass
else:
	print('No')
	return
if List[0][0] - List[0][1] == List[1][0] - List[1][1] and List[2][0] - List[2][1] == List[1][0] - List[1][1]:
	pass
else:
	print('No')
	return
if List[0][0] - List[0][2] == List[1][0] - List[1][2] and List[2][0] - List[2][2] == List[1][0] - List[1][2]:
	pass
else:
	print('No')
	return
print('Yes')


c = [list(map(int, input().split())) for _ in range(3)]
l = []
for i in c:
	l += i
if l[0] + l[4] == l[1] + l[3] and l[1] + l[5] == l[2] + l[4] and (l[3] + l[7] == l[4] + l[6]) and (l[4] + l[8] == l[5] + l[7]):
	print('Yes')
else:
	print('No')


import sys
input = sys.stdin.readline
N = 3
x = [0 for i in range(N)]
y = [0 for i in range(N)]
c = [[0 for i in range(N)] for i in range(N)]
for i in range(N):
	(c1, c2, c3) = map(int, input().split())
	c[i][0] = c1
	c[i][1] = c2
	c[i][2] = c3
x[0] = 0
for i in range(N):
	y[i] = c[0][i] - x[0]
x[1] = c[1][0] - y[0]
x[2] = c[2][0] - y[0]
flag = True
for i in range(N):
	for j in range(N):
		numx = x[i]
		numy = y[j]
		if not numx + numy == c[i][j]:
			flag = False
if flag:
	print('Yes')
else:
	print('No')


def is_valid(m, a, b):
	for i in range(3):
		for j in range(3):
			if m[i][j] != a[i] + b[j]:
				return 0
	return 1
m = []
for a0 in range(3):
	m.append(list(map(int, input().split())))
for a0 in range(101):
	b0 = m[0][0] - a0
	b1 = m[0][1] - a0
	b2 = m[0][2] - a0
	a1 = m[1][0] - b0
	a2 = m[2][0] - b0
	if is_valid(m, [a0, a1, a2], [b0, b1, b2]):
		print('Yes')
		return
print('No')


with open(0) as f:
	C = [list(map(int, line.split())) for line in f.readlines()]
b = [(C[i][1] - C[i][0], C[i][2] - C[i][1]) for i in range(3)]
a = [(C[1][j] - C[0][j], C[2][j] - C[1][j]) for j in range(3)]
print('Yes' if a[0] == a[1] == a[2] and b[0] == b[1] == b[2] else 'No')


c = [list(map(int, input().split())) for i in range(3)]
print(['Yes', 'No'][any([c[i][j] - c[i + 1][j] - c[i][j + 1] + c[i + 1][j + 1] for (i, j) in [[0, 0], [0, 1], [1, 0], [1, 1]]])])


l = [list(map(int, input().split())) for i in range(3)]
al = [l[i][0] for i in range(3)]
bl = [l[0][i] - al[0] for i in range(3)]
for i in range(3):
	for j in range(3):
		if al[i] + bl[j] != l[i][j]:
			print('No')
			exit()
print('Yes')


arr = []
for _ in range(3):
	arr += list(map(int, input().split()))
a = [0] * 3
b = [0] * 3
a[0] = 0
b[0] = arr[0]
b[1] = arr[1]
b[2] = arr[2]
a[1] = arr[4] - b[1]
a[2] = arr[8] - b[2]
tmp = [a[i] + b[j] for i in range(3) for j in range(3)]
print('Yes' if arr == tmp else 'No')


import sys
import pprint as pp

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

def MI():
	return list(map(int, sys.stdin.readline().split()))

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]
MAXSIZE = (1 << 31) - 1
MINSIZE = -(1 << 31) + 1
yes = 'Yes'
no = 'No'

def solver(line00, line01, line02, line10, line11, line12, line20, line21, line22):
	result = no
	a0 = 0
	b0 = line00
	b1 = line01 - a0
	b2 = line02 - a0
	a1 = line10 - line00
	a2 = line20 - line00
	if a1 + b1 == line11 and a1 + b2 == line12 and (a2 + b1 == line21) and (a2 + b2 == line22):
		result = yes
	return result

def __starting_point():
	(line00, line01, line02) = MI()
	(line10, line11, line12) = MI()
	(line20, line21, line22) = MI()
	print('{}'.format(solver(line00, line01, line02, line10, line11, line12, line20, line21, line22)))
__starting_point()


c = [list(map(int, input().split())) for _ in range(3)]
ans = 'Yes'
for i in range(len(c)):
	mi = min(c[i])
	(*c[i],) = map(lambda x: x - mi, c[i])
print('Yes' if c[0] == c[1] and c[1] == c[2] else 'No')


c = [[int(i) for i in input().split()] for _ in range(3)]
print('Yes') if c[0][0] + c[1][1] + c[2][2] == c[0][1] + c[1][2] + c[2][0] == c[0][2] + c[1][0] + c[2][1] else print('No')


c = [list(map(int, input().split())) for _ in range(3)]
a = [0, 0, 0]
b = [0, 0, 0]

def check(c, a, b):
	for i in range(3):
		for j in range(3):
			if a[i] + b[j] != c[i][j]:
				return False
	return True
for i in range(101):
	b[0] = i
	a[0] = c[0][0] - b[0]
	a[1] = c[1][0] - b[0]
	a[2] = c[2][0] - b[0]
	b[1] = c[0][1] - a[0]
	b[2] = c[0][2] - a[0]
	if check(c, a, b):
		print('Yes')
		return
print('No')


l = []
for i in range(3):
	(c1, c2, c3) = map(int, input().split())
	l.append([c1, c2, c3])
b1 = l[0][0]
b2 = l[1][0]
b3 = l[2][0]
flag = 0
for i in range(3):
	if not l[0][1] - b1 == l[1][1] - b2 == l[2][1] - b3:
		flag = 1
	if not l[0][2] - b1 == l[1][2] - b2 == l[2][2] - b3:
		flag = 1
if flag == 1:
	print('No', flush=True)
else:
	print('Yes', flush=True)


def main():
	c_lst = [list(map(int, input().split())) for _ in range(3)]
	c1 = c_lst[0][0] + c_lst[1][1] + c_lst[2][2]
	c2 = c_lst[1][0] + c_lst[2][1] + c_lst[0][2]
	c3 = c_lst[2][0] + c_lst[0][1] + c_lst[1][2]
	if c1 == c2 and c2 == c3:
		print('Yes')
	else:
		print('No')

def __starting_point():
	main()
__starting_point()


A = [[int(i) for i in input().split()] for i in range(3)]
ans = 'Yes'
for i in range(2):
	if A[i][0] - A[i + 1][0] != A[i][1] - A[i + 1][1] or A[i][1] - A[i + 1][1] != A[i][2] - A[i + 1][2]:
		ans = 'No'
print(ans)


c = [list(map(int, input().split())) for i in range(3)]
a = [c[0][i] - 0 for i in range(3)]
b = [c[i][0] - a[0] for i in range(3)]
d = [[a[i] + b[j] for i in range(3)] for j in range(3)]
print('Yes' if c == d else 'No')


c = [list(map(int, input().split())) for i in range(3)]
x = [0] * 3
y = [0] * 3
for i in range(3):
	y[i] = c[0][i] - x[0]
for i in range(3):
	x[i] = c[i][0] - y[0]
flag = True
for i in range(3):
	for j in range(3):
		if x[i] + y[j] != c[i][j]:
			flag = False
if flag:
	print('Yes')
else:
	print('No')


(b1, b2, b3) = map(int, input().split())
for _ in range(2):
	(x, y, z) = map(int, input().split())
	if x - b1 == y - b2 == z - b3:
		continue
	else:
		print('No')
		exit()
print('Yes')


c = [list(map(int, input().split())) for i in range(3)]
d = [0, 0, 0]
ans = 'Yes'
for i in range(2):
	for j in range(3):
		d[j] = c[i + 1][j] - c[i][j]
	if d[0] == d[1] and d[0] == d[2]:
		continue
	else:
		ans = 'No'
print(ans)


def main():
	grid = [list(map(int, input().split())) for i in range(3)]
	all = sum(sum(grid, []))
	a = [0] * 3
	b = [0] * 3
	for i1 in range(0, grid[0][0] + 1):
		a[0] = i1
		b[0] = grid[0][0] - i1
		for j2 in range(0, grid[1][1] + 1):
			a[1] = j2
			b[1] = grid[1][1] - j2
			for k3 in range(0, grid[2][2] + 1):
				a[2] = k3
				b[2] = grid[2][2] - k3
				if sum(a) * 3 + sum(b) * 3 == all:
					print('Yes')
					return
	print('No')

def __starting_point():
	main()
__starting_point()


L = [list(map(int, input().split())) for _ in range(3)]
ans = 'Yes'
if L[0][0] + L[1][1] != L[0][1] + L[1][0]:
	ans = 'No'
if L[0][1] + L[1][2] != L[0][2] + L[1][1]:
	ans = 'No'
if L[1][0] + L[2][1] != L[1][1] + L[2][0]:
	ans = 'No'
if L[1][1] + L[2][2] != L[1][2] + L[2][1]:
	ans = 'No'
print(ans)


c = [list(map(int, input().split())) for i in range(3)]
res = 0
ans = 0
for i in range(3):
	res += sum(c[i])
	ans += c[i][i] * 3
if res == ans:
	print('Yes')
else:
	print('No')


c = [[0] * 3] * 3
for i in range(3):
	c[i] = [int(x) for x in input().split()]
ans = False
if c[0][0] - c[0][1] == c[1][0] - c[1][1] == c[2][0] - c[2][1] and c[0][0] - c[0][2] == c[1][0] - c[1][2] == c[2][0] - c[2][2]:
	ans = True
if ans == True:
	print('Yes')
else:
	print('No')


c = [list(map(int, input().split())) for _ in range(3)]
diff0 = [x - y for (x, y) in zip(c[0], c[1])]
diff1 = [x - y for (x, y) in zip(c[0], c[2])]
if diff0[0] == diff0[1] and diff0[0] == diff0[2] and (diff1[0] == diff1[1]) and (diff1[0] == diff1[2]):
	print('Yes')
else:
	print('No')


import numpy as np
C = np.array([[int(x) for x in input().split()] for _ in range(3)])
ans = 'Yes'
for i in range(2):
	if not C[0, i + 1] - C[0, i] == C[1, i + 1] - C[1, i] == C[2, i + 1] - C[2, i]:
		ans = 'No'
	if not C[i + 1, 0] - C[i, 0] == C[i + 1, 1] - C[i, 1] == C[i + 1, 2] - C[i, 2]:
		ans = 'No'
print(ans)


c = [list(map(int, input().split())) for i in range(3)]
flag = False
for a0 in range(-100, 200):
	b0 = c[0][0] - a0
	a1 = c[1][0] - b0
	a2 = c[2][0] - b0
	b1 = c[0][1] - a0
	b2 = c[0][2] - a0
	if a1 + b1 == c[1][1] and a2 + b1 == c[2][1] and (a1 + b2 == c[1][2]) and (a2 + b2 == c[2][2]):
		flag = True
if flag:
	print('Yes')
else:
	print('No')


c = []
sum1 = 0
sum2 = 0
for i in range(3):
	c.append(list(map(int, input().split())))
	sum1 += sum(c[i])
	sum2 += c[i][i]
if sum1 == sum2 * 3:
	print('Yes')
else:
	print('No')


c = []
for i in range(3):
	c.append(list(map(int, input().split())))
flag = True
for i in range(2):
	if flag == True and c[i][1] - c[i][0] == c[i + 1][1] - c[i + 1][0] and (c[i][2] - c[i][1] == c[i + 1][2] - c[i + 1][1]) and (c[1][i] - c[0][i] == c[1][i + 1] - c[0][i + 1]) and (c[2][i] - c[1][i] == c[2][i + 1] - c[1][i + 1]):
		flag = True
	else:
		flag = False
if flag == True:
	print('Yes')
else:
	print('No')


l = []
for i in range(3):
	l.append(list(map(int, input().split())))
ch = []
for i in l:
	ch.append([i[0] - i[1], i[1] - i[2]])
if ch[0] == ch[1] and ch[1] == ch[2]:
	print('Yes')
else:
	print('No')


totalArray = []
answer = 'No'
Yoko = False
tate = False
for i in range(3):
	array = input().split(' ')
	for j in range(len(array)):
		totalArray.append(int(array[j]))
if totalArray[1] - totalArray[0] == totalArray[4] - totalArray[3] == totalArray[7] - totalArray[6] and totalArray[2] - totalArray[1] == totalArray[5] - totalArray[4] == totalArray[8] - totalArray[7]:
	Yoko = True
if totalArray[3] - totalArray[0] == totalArray[4] - totalArray[1] == totalArray[5] - totalArray[2] and totalArray[6] - totalArray[3] == totalArray[7] - totalArray[4] == totalArray[8] - totalArray[5]:
	tate = True
if Yoko == True and tate == True:
	print('Yes')
else:
	print('No')


field = []
result = 'Yes'
for i in range(3):
	field.append(list(map(int, input().split())))
for i in range(3):
	for j in range(3):
		if not (field[i][j] >= 0 and field[i][j] <= 100 * 2):
			result = 'No'
		if j == 0:
			pos_i0 = field[i][j]
		field[i][j] -= pos_i0
for j in range(3):
	if not (field[0][j] == field[1][j] and field[0][j] == field[2][j]):
		result = 'No'
print(result)


c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))
a1_a2 = c1[0] - c2[0]
a2_a3 = c2[0] - c3[0]
b1_b2 = c1[0] - c1[1]
b2_b3 = c1[1] - c1[2]
cnt = 0
if a1_a2 == c1[1] - c2[1] == c1[2] - c2[2]:
	cnt += 1
if a2_a3 == c2[1] - c3[1] == c2[2] - c3[2]:
	cnt += 1
if b1_b2 == c2[0] - c2[1] == c3[0] - c3[1]:
	cnt += 1
if b2_b3 == c2[1] - c2[2] == c3[1] - c3[2]:
	cnt += 1
if cnt == 4:
	print('Yes')
else:
	print('No')


c = [list(map(int, input().split())) for i in range(3)]
d1 = []
d2 = []
for i in range(3):
	d1.append(c[1][i] - c[0][i])
	d2.append(c[2][i] - c[0][i])
print('Yes' if d1[0] == d1[1] == d1[2] and d2[0] == d2[1] == d2[2] else 'No')


l = [list(map(int, input().split())) for _ in range(3)]
for i in range(2):
	if len(set([l[i + 1][j] - l[i][j] for j in range(3)])) != 1 or len(set([l[j][i + 1] - l[j][i] for j in range(3)])) != 1:
		print('No')
		break
else:
	print('Yes')


g = [[*map(int, input().split())] for _ in range(3)]
for h in [0, 1]:
	for w in [0, 1]:
		if g[h][w] + g[h + 1][w + 1] != g[h + 1][w] + g[h][w + 1]:
			exit(print('No'))
print('Yes')


c = [list(map(int, input().split())) for _ in [0] * 3]
(b1, b2, b3) = c[0]
(a2, a3) = (c[1][0] - b1, c[2][0] - b1)
if [c[1][1:], c[2][1:]] == [[a2 + b2, a2 + b3], [a3 + b2, a3 + b3]]:
	print('Yes')
else:
	print('No')


C = [list(map(int, input().split())) for _ in range(3)]
for i in range(3):
	temp = C[i][0]
	C[i] = [j - temp for j in C[i]]
if C[0] == C[1] and C[1] == C[2]:
	print('Yes')
else:
	print('No')


(d, e, f) = [int(i) for i in input().split()]
(x, y, z) = [int(i) for i in input().split()]
(s, t, u) = [int(i) for i in input().split()]
b = x - d
c = s - d
if b + e == y and b + f == z and (c + e == t) and (c + f == u):
	print('Yes')
else:
	print('No')


x = list(map(int, input().split()))
y = list(map(int, input().split()))
z = list(map(int, input().split()))
if x[1] - x[0] != y[1] - y[0] or y[1] - y[0] != z[1] - z[0] or x[2] - x[0] != y[2] - y[0] or (y[0] - x[0] != y[1] - x[1]) or (z[1] - x[1] != z[2] - x[2]) or (z[0] - x[0] != z[1] - x[1]) or (z[1] - x[1] != z[2] - x[2]):
	print('No')
else:
	print('Yes')


N = 3
c = [list(map(int, input().split())) for _ in range(N)]
ds = [sum((c[j][(i + j) % 3] for j in range(N))) for i in range(N)]
if ds[0] == ds[1] == ds[2]:
	print('Yes')
else:
	print('No')


c = [list(map(int, input().split())) for i in range(3)]
f = c[0][0]
s = c[0][1] - f
t = c[0][2] - f
for i in c:
	i_f = i[0]
	if i[1] != i_f + s or i[2] != i_f + t:
		print('No')
		exit()
print('Yes')


C = [list(map(int, input().split())) for _ in range(3)]
for i in range(1, 3):
	if C[i][0] - C[0][0] == C[i][1] - C[0][1] and C[i][0] - C[0][0] == C[i][2] - C[0][2]:
		pass
	else:
		print('No')
		exit()
print('Yes')


c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))
c = [c1, c2, c3]
for a1 in range(100):
	b1 = c1[0] - a1
	b2 = c1[1] - a1
	b3 = c1[2] - a1
	a21 = c2[0] - b1
	a22 = c2[1] - b2
	a23 = c2[2] - b3
	a31 = c3[0] - b1
	a32 = c3[1] - b2
	a33 = c3[2] - b3
	if a21 == a22 == a23 and a31 == a32 == a33:
		print('Yes')
		break
	elif a1 == 99:
		print('No')
		break
	else:
		continue