Street Network

No attempts yetTime limit1sMemory limit128 MB

Problem

The street network of a city consists of streets and nodes. Two or more streets may meet at a node. Every street is one-way. Two nodes may also be connected directly by more than one street, and a node may have a street that loops back to itself (a self-loop).

Write a program that answers the following three questions.

  1. Does there exist a route that starts at some node and traverses every street exactly once? (It may end back at the starting node or at a different node.)
  2. How many nodes can serve as the starting point of such a route?
  3. For each node $X$, how many routes of length $S$ start at $X$ and return to $X$? (A street or node may be used more than once.)

Input

The first line contains a positive integer $N$ ($N \le 50$), the number of nodes.

The second line contains a positive integer $S$ ($S \le 3$), the path length.

The next $N$ lines describe the network as a matrix. The value in row $I$, column $J$ is the number of streets going from node $I$ to node $J$. Nodes are numbered from $1$ to $N$.

Output

On the first line, print the string YES if there exists a route that starts at some node and traverses every street exactly once; otherwise print the string NO.

Only when the answer is YES, print the following two additional lines.

  • On the second line, print how many nodes can serve as a starting point of such a route.
  • On the third line, for each node compute the number of routes of length $S$ that leave the node and return to it, then print these $N$ values sorted in increasing order, separated by single spaces.

When the answer is NO, print only NO on the first line.