Please solve the programming task below using a self-contained code snippet in a markdown code block.

You are given three integers n, m and k. Consider the following algorithm to find the maximum element of an array of positive integers:

You should build the array arr which has the following properties:

arr has exactly n integers.
1 <= arr[i] <= m where (0 <= i < n).
After applying the mentioned algorithm to arr, the value search_cost is equal to k.

Return the number of ways to build the array arr under the mentioned conditions. As the answer may grow large, the answer must be computed modulo 109 + 7.
 
Please complete the following python code precisely:
```python
class Solution:
    def numOfArrays(self, n: int, m: int, k: int) -> int:
```