Abnormal Permutation Pairs (hard version)

Problem Name:
Abnormal Permutation Pairs (hard version)
Site:CodeForces
Links:
Tags:
Problem setters: