Help in Codeforces 1043D

I am not able to solve this problem even after reading the editorial, can anyone help me with this?
I think if we consider the first permutation we can check If each of its substrings exists in all of the other permutations, but I don’t know how to really implement this approach?