Great problem, with many algos & data structures
Interesting problem
Bitmasks save the day