[提交][状态][讨论版]

## 题目描述

Given an n*m matrix, you are asked to judge if it's fantastic. The rule is: firstly, choose min (n, m) numbers from it, meanwhile you should make sure any two numbers you select will not at the same row or same column. Of course, you may have many different ways to get the numbers. For every way, if the sum of all selected numbers is always same, you may say the matrix is fantastic.

## 输入

The first line contains an integer T, stands for the number of test cases. (1<=T<=100)

T cases follow, for every case:

The first line contains two integers n and m. (1 <= n, m <= 50)

Then n lines follows, each line contains m integers. Every number in the matrix will between -100000 and 100000.

## 输出

For every case, if it is a fantastic matrix, output “YES” in one line, otherwise output “NO”.

## 样例输入

3
2 2
1 3
2 4
2 3
1 1 1
1 1 1
2 1
2
3


## 样例输出

YES
YES
NO


[提交][状态][讨论版]