logo AlgoBeat OnlineJudge
登录 注册

#208476. [USACO23FEB] Problem Setting P

内存限制:512 MiB 时间限制:2000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Note: The memory limit for this problem is 512MB, twice the default.

Farmer John created problems. He then recruited test-solvers, each of which rated every problem as "easy" or "hard."

His goal is now to create a problemset arranged in increasing order of difficulty, consisting of some subset of his problems arranged in some order. There must exist no pair of problems such that some test-solver thinks the problem later in the order is easy but the problem earlier in the order is hard.

Count the number of distinct nonempty problemsets he can form, modulo .

输入格式

The first line contains and .

The next lines each contain a string of length . The -th character of this string is E if the test-solver thinks the ith problem is easy, or H otherwise.

输出格式

The number of distinct problemsets FJ can form, modulo .

样例

样例输入 1

3 1
EHE

样例输出 1

9

样例输入 2

10 6
EHEEEHHEEH
EHHHEEHHHE
EHEHEHEEHH
HEHEEEHEEE
HHEEHEEEHE
EHHEEEEEHE

样例输出 2

33

数据范围与提示

Explanation for Sample 1

The nine possible problemsets are as follows:









Note that the order of the problems within the problemset matters.

SCORING

  • Inputs :
  • Inputs :
  • Inputs : No additional constraints.