There are seats arranged in a circle, numbered in clockwise order.
For each (), seats and are neighbours. Seats and are also neighbours.
For each (), seats and are opposite each other.
Some of the seats are occupied. For each (), seat is occupied by exactly one person if is o, and is empty if is x.
You want to form pairs of people subject to the following conditions.
- Each person belongs to at most one pair.
- Each pair consists of two people seated in neighbouring or opposite seats.
Find the maximum possible number of pairs and the number of ways to achieve this maximum.
Two ways of forming pairs are considered different if their sets of unordered pairs differ.