Count pairs of n-digit scores where each player, seeing only half of both boards, can deduce all 2n digits.
Medium7CombinatoricsBit manipulationMathNo attempts yetTime limit2sMemory limit512 MBAlice and Bob play a game in which they score points. Each of them has an n-digit scoreboard that shows a base 10 number padded with leading zeros. Every digit is drawn on a seven-segment display.

The seven segments are the top, upper left, upper right, middle, lower left, lower right and bottom. Each digit lights up these segments:
| Digit | Lit segments |
|---|---|
| 0 | top, upper left, upper right, lower left, lower right, bottom |
| 1 | upper right, lower right |
| 2 | top, upper right, middle, lower left, bottom |
| 3 | top, upper right, middle, lower right, bottom |
| 4 | upper left, upper right, middle, lower right |
| 5 | top, upper left, middle, lower right, bottom |
| 6 | top, upper left, middle, lower left, lower right, bottom |
| 7 | top, upper right, lower right |
| 8 | all seven |
| 9 | top, upper left, upper right, middle, lower right, bottom |
For some odd reason the two players cannot see the scoreboards entirely. Alice sees only the lower half of her own scoreboard and the upper half of Bob's scoreboard. Bob sees only the upper half of his own scoreboard and the upper half of Alice's scoreboard. The upper half is the top, upper left, upper right and middle segments; the lower half is the middle, lower left, lower right and bottom segments. The middle horizontal segment belongs to both halves, so both players always see it. For example, someone who sees the upper half of an eight can conclude that the digit is not a zero.

Figure I.1: an example situation for n=4
A pair of n-digit scores is fully known if both players work out all 2n digits from what they see. The players cannot communicate.
Count the score pairs that are fully known.
The first line contains the number of digits n (1≤n≤20).
Print the number of score pairs that can be displayed on the two n-digit scoreboards and are fully known by both players.