Under construction

Still being built. Things may change

Bingo

Time limit1sMemory limit1024 MB

Summary
Given a partly colored n by n bingo board and k more random calls, find the expected number of fully colored lines, scaled by (n^2)! modulo 1e9+7.
Level

Medium5 of 10

Topics
Math, Combinatorics, Probability, Implementation
Solved
No attempts yet

Problem

Students in a probability and statistics course are playing bingo. The game follows these rules.

  • Each participant writes the integers from 1 to n2n^2 into the cells of an n×nn \times n square board, one per cell, with no repeats.
  • In each round, the host calls one of the integers from 1 to n2n^2. A number that has already been called cannot be chosen again.
  • Each participant finds the cell containing the called number on their own board and fills it with color.
  • When the host decides to stop calling numbers, the game ends and scores are computed. A participant's score is the number of lines made up only of colored cells. There are 2n+22n+2 lines to consider: nn rows, nn columns, and 2 diagonals.

The score of the board above is 5.

The host is completely fair. Each turn, the host picks uniformly at random from the numbers that may be called.

You are given the board of participant AA, reflecting the game so far. The host will call exactly kk more numbers. Find the expected final score of AA.

Input

The first line contains two integers nn and kk. (1≤n≤100(1 \le n \le 100, 0≤k≤n2)0 \le k \le n^2)

From the second line onward, the state of the board is given as nn strings of length nn consisting of 00 and 11. 00 means the cell is not colored, and 11 means the cell is colored.

The given board has at least kk uncolored cells.

Output

Let XX be the expected score of AA. Print a single integer on the first line: the value of (n2)!×X(n^2)! \times X modulo the prime 109+710^9+7.

Within the given input range, (n2)!×X(n^2)! \times X is always an integer.

Examples5

  1. Example 1

    Input
    2 2
    00
    00
    
    Expected output
    24
    
  2. Example 2

    Input
    2 0
    10
    11
    
    Expected output
    72
    
  3. Example 3

    Input
    5 24
    00000
    00000
    00000
    00000
    00000
    
    Expected output
    831030901
    
  4. Example 4

    Input
    5 4
    00000
    00000
    00100
    00000
    00000
    
    Expected output
    182548743
    
  5. Example 5

    Input
    6 17
    000010
    000100
    001000
    010000
    100000
    000001
    
    Expected output
    389132331