#include #include #include #define let auto #define fn auto #define usize size_t using namespace std; const usize MOD = 1'000'000'007; fn fastio() { ios::sync_with_stdio(false); cin.tie(nullptr); } fn count_ilove(usize x, const vector &hates) -> usize { if (x == 0) return 0; string s = to_string(x); usize n = s.size(); vector>> dp(n + 1, vector>(2, vector(2, 0))); dp[0][1][0] = 1; for (usize pos = 0; pos < n; pos++) { for (usize tight = 0; tight <= 1; tight++) { for (usize started = 0; started <= 1; started++) { usize limit = tight ? (s[pos] - '0') : 9; for (usize digit = 0; digit <= limit; digit++) { bool is_hated = false; for (usize h: hates) { if (h == digit) { is_hated = true; break; } } if (is_hated) continue; bool next_started = started || (digit != 0); usize next_tight = (tight && digit == limit) ? 1 : 0; if (!next_started && pos == n - 1) continue; dp[pos + 1][next_tight][next_started] += dp[pos][tight][started]; } } } } usize result = 0; for (usize tight = 0; tight <= 1; tight++) { result += dp[n][tight][1]; } return result; } fn main() -> int { fastio(); usize n, l, r; cin >> n >> l >> r; vector hates(n); for (usize i = 0; i < n; i++) { cin >> hates[i]; } usize ret = (count_ilove(r, hates) + 2 * MOD - (count_ilove(l - 1, hates))) % MOD; cout << ret % MOD << "\n"; }