Diti and Friends

0

0 votes
Problem

Diti's friends are visiting her house for her birthday. The party has N x M members including Diti. Diti's father has organized the party and he wants everyone to return satisfied. A member will be satisfied only if he/she has a piece of chocolate.

Diti's father organized everyone into N rows with each row having M members. Diti's father may initially give chocolates to any number of members. Consider every chocolate to be sufficiently large such that it can be shared with many people. If at any point of time, a person who has a piece of chocolate sees that his neighbour also has a piece of chocolate, he feels sorry for all his other neighbours who don't have a piece of chocolate and shares a part of his chocolate with all of them.

Given the initial distribution of chocolates, report whether everyone will get a piece of chocolate or not, also report the minimum number of chocolates that should be added in the initial configuration such that every child gets at least one piece of it.

Note: Two cells are neighbours if they share a common edge.

Input

The first line contains an integer T, number of test cases. Every test case starts with 2 numbers N and M. The next N lines contain M integers each (without spaces). If the integer on ith row and jth column is 1 it means that that member initially has chocolate whereas 0 means initially the member doesn't have any chocolate.

Output

For every test case output the answer to question in a new line. Output "yes" (without quotes) if the initial distribution results in satisfaction of everyone or "no" (without quotes) if the initial distribution doesn't result in satisfaction of everyone. For each test case also print an additional number after a single space indicating the minimum number of chocolates father needs to initially distribute that will result in satisfaction of everyone.

Constraints

1 ≤ T ≤ 5
1 ≤ N ≤ 102
1 ≤ M ≤ 102

Author : Sayan
Tester : Ravi

Time Limit: 2
Memory Limit: 256
Source Limit:
Editor Image

?