Nearest Beautiful Number (hard version)

Problem Name:
Nearest Beautiful Number (hard version)
Site:CodeForces
Links:
Tags:
Problem setters: