Farmer John's hobby of conducting high-energy physics experiments on
weekends has backfired, causing N wormholes (2 <= N <= 12, N even) to
materialize on his farm, each located at a distinct point on the 2D map of
his farm.
According to his calculations, Farmer John knows that his wormholes will
form N/2 connected pairs. For example, if wormholes A and B are connected
as a pair, then any object entering wormhole A will exit wormhole B moving
in the same direction, and any object entering wormhole B will similarly
exit from wormhole A moving in the same direction. This can have rather
unpleasant consequences. For example, suppose there are two paired
wormholes A at (0,0) and B at (1,0), and that Bessie the cow starts from
position (1/2,0) moving in the +x direction. Bessie will enter wormhole B,
exit from A, then enter B again, and so on, getting trapped in an infinite
cycle!
Farmer John knows the exact location of each wormhole on his farm. He
knows that Bessie the cow always walks in the +x direction, although he
does not remember where Bessie is currently located. Please help Farmer
John count the number of distinct pairings of the wormholes such that
Bessie could possibly get trapped in an infinite cycle if she starts from
an unlucky position.