require "big" q, k = read_line.split.map &.to_i puts ((10.to_big_i**(q - 1) - 1 - k) // q + 1) % (10**9 + 7)