Problem

9 /12


Counting by amount

Problem

Write a program that determines how many -digit numbers are in the matrix, the sum of the digits of each of which is a multiple of .

Input
The first line contains, separated by a space, the dimensions of the matrix: the number of rows N and the number of columns M (\(1 <= N , M <= 100\)). The following N lines contain matrix rows, each – by M natural numbers separated by spaces. Then the numbers K and R .

are entered on two separate lines.

Imprint
The program should output one number – the number of K -digit numbers, the sum of the digits of each of which is a multiple of R .  

Example
# Input Output
1 5 5
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25
2
3
5