Bob's confusion

3.4

5 votes
Algorithms, Basics of Greedy Algorithms, Greedy Algorithms
Problem

You are given a 3×3 grid. Each number in the grid is represented by Cij where (i,j) denotes the square at the ith row from the top and jth column from the left.

Bob gets confused. According to him, there are six integers a1,a2,a3,b1,b2,b3 whose values are fixed and the number written in the square (i,j) is equal to ai+bj. You are required to determine whether Bob is correct or not.

Input format

  • The first line contains an integer T denoting the number of test cases.
  • Next three lines contain three space-separated integers Ci1,Ci2, and Ci3 denoting the ith row of grid C.

Output format

For each test case, print YES if Bob's statement is correct. Otherwise, print NO in a new line.

Constraints

1T2000000Cij1000000000

Sample Input
2
3 4 7
4 5 8
3 4 7
1 3 1
0 1 0
0 2 3
Sample Output
YES
NO
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

For first testcase, the set of 6 integers (a1,a2,a3,b1,b2,b3) = (2,3,2,1,2,5). Therfore, Lucky's statement is correct.

For second testcase, there are no possible set of 6 integers. Therefore, Lucky's statement must be incorrect.

Editor Image

?