Shuffle Hashing

CodeForces - 1278A