Seating Arrangements (hard version)

Problem Name:
Seating Arrangements (hard version)
Site:CodeForces
Links:
Tags:
Problem setters: