Good Numbers (hard version)

Problem Name:
Good Numbers (hard version)
Site:CodeForces
Links:
Tags:
Problem setters: