10021. Walking on the Safe Side

輸入格式

• $1 \le N, \; M \le 100$

範例輸入

5 50 0 0 0 00 0 0 0 00 0 0 0 00 0 0 0 00 0 0 0 06 50 0 0 0 00 1 0 1 00 1 1 1 00 0 1 1 00 1 1 0 00 0 0 0 06 50 0 0 0 00 1 0 1 00 1 0 1 00 0 0 1 00 1 0 0 00 0 0 0 0


範例輸出

7028