Common Knowledge

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 MB

Problem

Alice and Bob play a game in which they score points. Each of them has an nn-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:

DigitLit segments
0top, upper left, upper right, lower left, lower right, bottom
1upper right, lower right
2top, upper right, middle, lower left, bottom
3top, upper right, middle, lower right, bottom
4upper left, upper right, middle, lower right
5top, upper left, middle, lower right, bottom
6top, upper left, middle, lower left, lower right, bottom
7top, upper right, lower right
8all seven
9top, 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=4n = 4

A pair of nn-digit scores is fully known if both players work out all 2n2n digits from what they see. The players cannot communicate.

Count the score pairs that are fully known.

Input

The first line contains the number of digits nn (1n201 \le n \le 20).

Output

Print the number of score pairs that can be displayed on the two nn-digit scoreboards and are fully known by both players.