Gadget Construction
Time limit1sMemory limit1024 MB
Count subsets of at least 4 cogs whose convex hull alternates colors around its vertices, with interior cogs of any color, modulo 1e9+7.
- Level
Hard8 of 10
- Topics
- Geometry, Dynamic programming, Combinatorics
- Solved
- No attempts yet
Statement
Grigory is an engineer who loves developing drones and geometry. He solves most problems himself, but today he faces one that his skills alone cannot solve. You are his best sidekick, and your task is to help him.
There are cogs on the Cartesian plane. The -th cog is at and has color . If is b, the cog is black. If is w, the cog is white. No three cogs lie on the same line.
Grigory chooses a subset of or more of the cogs. He then places a loop of chains around the cogs. The loop satisfies two conditions. Every cog in either touches the loop or lies inside it. The total length of the chains is minimal.

Consider the cogs in that touch the loop. Any two cogs that are adjacent on the loop must have different colors, or the gadget does not work. A cog in that does not touch the loop may have any color.
How many different sets can Grigory choose to build a properly working gadget? Since the answer can be very large, print it modulo .
Input
The first line contains an integer . Each of the next lines contains two integers , and a character , which give the coordinates and color of the -th cog.
Output
Print the number of valid sets modulo .
Constraints
. For every , , and is b or w. For , . No three cogs lie on the same line.