#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int dig(char c) { return c - '0'; }
bool good(string s, int m, int d) {
  int rem = 0;
  for (int i = 0; i < (int)s.length(); i++) {
    if (i & 1) {
      if (dig(s[i]) != d) {
        return false;
      }
    } else if (dig(s[i]) == d) {
      return false;
    }
    rem = (rem * 10 + dig(s[i])) % m;
  }
  return rem == 0;
}
int solve(string s, int m, int d) {
  int n = (int)s.length();
  s = "#" + s;
  int dp[n + 1][m][2];
  memset(dp, 0, sizeof dp);
  dp[0][0][1] = 1;
  for (int i = 1; i <= n; i++) {
    for (int rem = 0; rem < m; rem++) {
      if (i % 2 == 0) {
        dp[i][(rem * 10 + d) % m][0] =
            (dp[i][(rem * 10 + d) % m][0] + dp[i - 1][rem][0]) % MOD;
        if (d < dig(s[i])) {
          dp[i][(rem * 10 + d) % m][0] =
              (dp[i][(rem * 10 + d) % m][0] + dp[i - 1][rem][1]) % MOD;
        }
        if (d == dig(s[i])) {
          dp[i][(rem * 10 + d) % m][1] =
              (dp[i][(rem * 10 + d) % m][1] + dp[i - 1][rem][1]) % MOD;
        }
      } else {
        for (int dg = (i == 0 ? 1 : 0); dg <= 9; dg++) {
          if (dg == d) continue;
          dp[i][(rem * 10 + dg) % m][0] =
              (dp[i][(rem * 10 + dg) % m][0] + dp[i - 1][rem][0]) % MOD;
          if (dg == dig(s[i])) {
            dp[i][(rem * 10 + dg) % m][1] =
                (dp[i][(rem * 10 + dg) % m][1] + dp[i - 1][rem][1]) % MOD;
          }
          if (dg < dig(s[i])) {
            dp[i][(rem * 10 + dg) % m][0] =
                (dp[i][(rem * 10 + dg) % m][0] + dp[i - 1][rem][1]) % MOD;
          }
        }
      }
    }
  }
  return (dp[n][0][0] + dp[n][0][1]) % MOD;
}
int main() {
  int m, d;
  while (scanf("%d%d", &m, &d) == 2) {
    string a, b;
    cin >> a >> b;
    int res =
        ((solve(b, m, d) - solve(a, m, d) + good(a, m, d)) % MOD + MOD) % MOD;
    printf("%d\n", res);
  }
}

### Prompt

Construct a cpp code solution to the problem outlined:

Consider the decimal presentation of an integer. Let's call a number d-magic if digit d appears in decimal presentation of the number on even positions and nowhere else.

For example, the numbers 1727374, 17, 1 are 7-magic but 77, 7, 123, 34, 71 are not 7-magic. On the other hand the number 7 is 0-magic, 123 is 2-magic, 34 is 4-magic and 71 is 1-magic.

Find the number of d-magic numbers in the segment [a, b] that are multiple of m. Because the answer can be very huge you should only find its value modulo 109 + 7 (so you should find the remainder after dividing by 109 + 7).

Input

The first line contains two integers m, d (1 ≤ m ≤ 2000, 0 ≤ d ≤ 9) — the parameters from the problem statement.

The second line contains positive integer a in decimal presentation (without leading zeroes).

The third line contains positive integer b in decimal presentation (without leading zeroes).

It is guaranteed that a ≤ b, the number of digits in a and b are the same and don't exceed 2000.

Output

Print the only integer a — the remainder after dividing by 109 + 7 of the number of d-magic numbers in segment [a, b] that are multiple of m.

Examples

Input

2 6
10
99


Output

8


Input

2 0
1
9


Output

4


Input

19 7
1000
9999


Output

6

Note

The numbers from the answer of the first example are 16, 26, 36, 46, 56, 76, 86 and 96.

The numbers from the answer of the second example are 2, 4, 6 and 8.

The numbers from the answer of the third example are 1767, 2717, 5757, 6707, 8797 and 9747.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int dig(char c) { return c - '0'; }
bool good(string s, int m, int d) {
  int rem = 0;
  for (int i = 0; i < (int)s.length(); i++) {
    if (i & 1) {
      if (dig(s[i]) != d) {
        return false;
      }
    } else if (dig(s[i]) == d) {
      return false;
    }
    rem = (rem * 10 + dig(s[i])) % m;
  }
  return rem == 0;
}
int solve(string s, int m, int d) {
  int n = (int)s.length();
  s = "#" + s;
  int dp[n + 1][m][2];
  memset(dp, 0, sizeof dp);
  dp[0][0][1] = 1;
  for (int i = 1; i <= n; i++) {
    for (int rem = 0; rem < m; rem++) {
      if (i % 2 == 0) {
        dp[i][(rem * 10 + d) % m][0] =
            (dp[i][(rem * 10 + d) % m][0] + dp[i - 1][rem][0]) % MOD;
        if (d < dig(s[i])) {
          dp[i][(rem * 10 + d) % m][0] =
              (dp[i][(rem * 10 + d) % m][0] + dp[i - 1][rem][1]) % MOD;
        }
        if (d == dig(s[i])) {
          dp[i][(rem * 10 + d) % m][1] =
              (dp[i][(rem * 10 + d) % m][1] + dp[i - 1][rem][1]) % MOD;
        }
      } else {
        for (int dg = (i == 0 ? 1 : 0); dg <= 9; dg++) {
          if (dg == d) continue;
          dp[i][(rem * 10 + dg) % m][0] =
              (dp[i][(rem * 10 + dg) % m][0] + dp[i - 1][rem][0]) % MOD;
          if (dg == dig(s[i])) {
            dp[i][(rem * 10 + dg) % m][1] =
                (dp[i][(rem * 10 + dg) % m][1] + dp[i - 1][rem][1]) % MOD;
          }
          if (dg < dig(s[i])) {
            dp[i][(rem * 10 + dg) % m][0] =
                (dp[i][(rem * 10 + dg) % m][0] + dp[i - 1][rem][1]) % MOD;
          }
        }
      }
    }
  }
  return (dp[n][0][0] + dp[n][0][1]) % MOD;
}
int main() {
  int m, d;
  while (scanf("%d%d", &m, &d) == 2) {
    string a, b;
    cin >> a >> b;
    int res =
        ((solve(b, m, d) - solve(a, m, d) + good(a, m, d)) % MOD + MOD) % MOD;
    printf("%d\n", res);
  }
}

```