## The game of Mahjong is played with tiles belonging to $s$ suits. Each tile also has a number in the range $1\ldots n$, and for each suit/number combination there are exactly four indistinguishable tiles with that suit and number. (The real Mahjong game also contains other bonus tiles, but those will not feature in this problem.)

A winning hand is a collection of $3t+2$ Tiles (where $t$ is a fixed integer) that can be arranged as $t$ Triples and one Pair, where:

A Triple is either a Chow or a Pung

A Chow is three tiles of the same suit and consecutive numbers

A Pung is three identical tiles (same suit and same number)

A Pair is two identical tiles (same suit and same number)

For example, here is a winning hand with $n=9$, $s=3$, $t=4$, consisting in this case of two Chows, two Pungs, and one Pair:

Note that sometimes the same collection of tiles can be represented as $t$ Triples and one Pair in more than one way. This only counts as one winning hand. For example, this is considered to be the same winning hand as above, because it consists of the same tiles:

Let $w(n, s, t)$ be the number of distinct winning hands formed of $t$ Triples and one Pair, where there are $s$ suits available and tiles are numbered up to $n$.

For example, with a single suit and tiles numbered up to $4$, we have $w(4, 1, 1) = 20$: there are $12$ winning hands consisting of a Pung and a Pair, and another $8$ containing a Chow and a Pair. You are also given that $w(9, 1, 4) = 13259$, $w(9, 3, 4) = 5237550$, and $w(1000, 1000, 5) \equiv 107662178 \pmod{1\,000\,000\,007}$.

Find $w(10^8, 10^8, 30)$. Give your answer modulo $1\,000\,000\,007$.

### It appears you have a question about combinatorics in the game of Mahjong. This is a very complex problem, and solving it can take a significant amount of computation and understanding of both combinatorics and the game rules themselves. Therefore, let’s discuss a general approach as a solution is unlikely to be computed manually.

You may consider using dynamic programming to approach this problem. Dynamic programming is a method for solving complex problems by breaking it down into simpler subproblems, solving the subproblem, and storing the solution to each subproblem so as to avoid solving the subproblem multiple times.

Let’s denote DP[i][j][k][l] where:

– i : considering i-th suit

– j : already got j pairs or triples

– k : already got k actual tiles

– l : got l tiles in current triple or pair

And then, you would perform several iterations (from i = 0 to n, from j = 0 to t, from k = 0 to 3t+2 and from l = 0 to 3) in order to calculate the number of distinct combinations for a given state of the game.

This approach takes into account the restrictions posed by the game, and as such would result in accurate counts under the rules of Mahjong.

However, do note that enumerating over such large ranges (10^8) is computationally expensive and you need to apply modulo operation to keep numbers manageable.

Therefore, this problem seems to be made for high-performance calculations and you would probably need to use a computer program to calculate $w(10^8, 10^8, 30) \mod 1,000,000,007.$

It is beyond the scope of human capabilities to manually then calculate this on a piece of paper, and it seems to be a programming task suited for a computer science program in languages like Python, C++ or Java.

##### More Answers:

Finite Sequence GeneratorCube-full Divisors

Random Rectangles