AquaMoon and Stolen String

CodeForces - 1546B