Polycarpus the Safecracker

CodeForces - 161E