Codeforces Round #595 (Div. 3) C2. Good Numbers (hard version)

NoSuchKey