Problem8187--USACO 2023 February Contest, Platinum Problem 2. Problem Setting

8187: USACO 2023 February Contest, Platinum Problem 2. Problem Setting

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 512 MiB

Description

Farmer John created $N\ (1≤N≤10^5)$ problems. He then recruited $M\ (1≤M≤20)$ 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 N 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 $10^9+7$.

Input

The first line contains N and M. The next M lines each contain a string of length N. The i-th character of this string is E if the test-solver thinks the i-th problem is easy, or H otherwise.

Output

The number of distinct problemsets FJ can form, modulo $10^9+7$.

Sample 1 Input

3 1
EHE

Sample 1 Output

9

The nine possible problemsets are as follows:

[1]
[1,2]
[1,3]
[1,3,2]
[2]
[3]
[3,1]
[3,2]
[3,1,2]

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

Sample 2 Input

10 6
EHEEEHHEEH
EHHHEEHHHE
EHEHEHEEHH
HEHEEEHEEE
HHEEHEEEHE
EHHEEEEEHE

Sample 2 Output

33

HINT

相同题目:USACO Platinum

Source/Category