John thinks 4 and 7 are lucky digits, and all other digits are not lucky. A lucky number is a number that contains only lucky digits in decimal notation.
A lucky sequence is a sequence of length numbers A[0], A[1], ..., A[length - 1] that satisfies all of the following properties:
- Each number A[i] is lucky, where 0 <= i < length.
- For each i, where 0 <= i < length, there exists at least one j such that A[i] = numbers[j].
- For each i, where 0 <= i < length - 1, the last digit of A[i] is the same as the first digit of A[i + 1].
You are given a int[] numbers and an int length. Return the number of distinct lucky sequences modulo 1234567891.
|