mod io { pub fn scan(r: &mut R) -> Vec { let mut res = Vec::new(); loop { let buf = match r.fill_buf() { Ok(buf) => buf, Err(e) if e.kind() == std::io::ErrorKind::Interrupted => continue, Err(e) => panic!(e), }; let (done, used, buf) = { match buf.iter().position(u8::is_ascii_whitespace) { Some(i) => (i > 0 || res.len() > 0, i + 1, &buf[..i]), None => (buf.is_empty(), buf.len(), buf), } }; res.extend_from_slice(buf); r.consume(used); if done { return res; } } } } #[allow(dead_code)] mod mod_int { #[derive(Clone, Copy)] pub struct ModInt(pub i64); impl ModInt { const MOD: i64 = 1_000_000_007; pub fn new(x: i64) -> ModInt { Self(x % Self::MOD) } } impl std::ops::Add for ModInt { type Output = Self; fn add(self, other: Self) -> Self { let x = self.0 + other.0; if x < Self::MOD { Self(x) } else { Self(x - Self::MOD) } } } impl std::ops::AddAssign for ModInt { fn add_assign(&mut self, other: Self) { *self = *self + other; } } impl std::ops::Sub for ModInt { type Output = Self; fn sub(self, other: Self) -> Self { if self.0 < other.0 { Self(self.0 + Self::MOD - other.0) } else { Self(self.0 - other.0) } } } impl std::ops::SubAssign for ModInt { fn sub_assign(&mut self, other: Self) { *self = *self - other; } } impl std::ops::Mul for ModInt { type Output = Self; fn mul(self, other: Self) -> Self { Self::new(self.0 * other.0) } } impl std::ops::MulAssign for ModInt { fn mul_assign(&mut self, other: Self) { *self = *self * other; } } impl std::fmt::Display for ModInt { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", self.0) } } impl From for ModInt { fn from(x: usize) -> Self { Self(x as i64) } } } use mod_int::ModInt; #[allow(unused_macros)] fn run(reader: &mut R, writer: &mut W) { macro_rules! scan { ([$t:tt; $n:expr]) => ((0..$n).map(|_| scan!($t)).collect::>()); (($($t:tt),*)) => (($(scan!($t)),*)); ([u8]) => (io::scan(reader)); (String) => (unsafe { String::from_utf8_unchecked(scan!([u8])) }); ($t:ty) => (scan!(String).parse::<$t>().unwrap()); } macro_rules! print { ($($arg:tt)*) => (write!(writer, $($arg)*).ok()); } macro_rules! println { ($($arg:tt)*) => (writeln!(writer, $($arg)*).ok()); } let n = scan!([u8]); let mut dp = [ModInt(1), ModInt(0)]; for (k, d) in n.into_iter().enumerate() { let d = (d - b'0') as usize; let mut next = [ModInt(0), ModInt(0)]; for i in 1..10 { let v = ModInt::from(i); if i < d { next[1] += (dp[0] + dp[1]) * v; } else if i == d { next[0] += dp[0] * v; next[1] += dp[1] * v; } else { next[1] += dp[1] * v; } if k > 0 { next[1] += v; } } dp = next; } println!("{}", dp[0] + dp[1]); } fn main() { let (stdin, stdout) = (std::io::stdin(), std::io::stdout()); let mut reader = std::io::BufReader::new(stdin.lock()); let mut writer = std::io::BufWriter::new(stdout.lock()); run(&mut reader, &mut writer); }