Submit solution

Points:
15 (partial)

Time limit:
1.0s

Memory limit:
64M

Author:

Problem type

Allowed languages

Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, ~~CommonLisp~~, D, Dart, F#, Forth, Fortran, Go, ~~Groovy~~, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, ~~Nim~~, ~~ObjC~~, OCaml, ~~Octave~~, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

You are given a digit array of length . You must find the number of integers between and (inclusive) satisfying the following condition, modulo :

- The digits for all show up at least once in the integer.

#### Input Specification

The first line will contain the integer .

The next line will contain integers, . It is guaranteed is distinct.

The next line will contain the integer .

#### Output Specification

Output the number of integers satisfying the condition, modulo .

#### Sample Input 1

```
1
1
11
```

#### Sample Output 1

`3`

#### Explanation For Sample 1

The three integers satisfying the constraints are:

`1`

`10`

`11`

#### Sample Input 2

```
5
3 9 2 0 1
512309002821093
```

#### Sample Output 2

`891474356`

## Comments

Remember that leading zeros do not count.