B2. Character Swap (Hard Version)

This problem is different from the easy version. In this version Ujan makes at most 2

12-30 10:36