codeforces438 D. The Child and Sequence

NoSuchKey