Intersection of Permutations

CodeForces - 1093E