Alternating Deck (hard version)

Problem Name:
Alternating Deck (hard version)
Site:CodeForces
Links:
Tags:
Problem setters: