#F. (初中组)上学路

    Type: Default 1000ms 256MiB

(初中组)上学路

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Background

Special for beginners, ^_^

Description

小明住在一个方方正正的街区内,这个街区有 n×mn\times m 个路口,恰好排成一个 nnmm 列的长方形。小明住在左上角的路口处,而学校则位于右下角的路口。 这天,小明在上学的路上,突然想到一个问题,那就是他如果走最短路径去学校,即只往右或者往下走,能有多少种方法去到学校。但是很不巧,今天有些路口在维修,所以这些路口是不能走的。那么在这一天,小明有多少种前往学校的方案呢?由于这个数可能很大,小明只需要你回答这个数模 998244353998244353 的结果。

Format

Input

第一行两个正整数 nnmm 表示街区有 nnmm 列; 接下来 nn 行,每行 mm 个数,代表街区的情况。数字是 11 表示这个街区可以通过,数字是 00 表示这个街区不能通过。 保证小明家和学校位置的数字是 11,且保证一定有可以走到学校的方案。

Output

一个正整数表示小明走到学校的方案总数,对 998244353998244353 取模。

Samples

3 3
1 1 0
1 1 1
0 1 1
4

Limitation

1n,m5001\leq n, m\leq 500

水题过家家

Not Attended
Status
Done
Rule
IOI
Problem
8
Start at
2023-5-20 8:00
End at
2023-5-20 12:00
Duration
4 hour(s)
Host
Partic.
49