n,m = map(int,input().split()) a = [] num_of_1_row = [0]*n num_of_1_col = [0]*m for i in range(n): cur = list(map(int,input().split())) # num_of_1_row.append(cur.count(1)) a.append(cur) for i in range(n): for j in range(m): if a[i][j] == 1: num_of_1_row[i] += 1 num_of_1_col[j] += 1 p = 10**9+7 sub1 ...