A well-known hacker Vasya, after seeing Petryk's excellent game, decided to change it a little. He modified the subroutine responsible for displaying the participant's score so that each of the segments used in the image of a digit could appear on the screen or be omitted. As a result, the player could not always easily determine their score. For example, the number could be represented as:

However, in this way, the number and some other numbers could also be displayed. Your task is, given such a representation, to determine how many integers (possible scores) could have been displayed in this way.
The first line contains the integer (1 \leq K \leq 9), the number of digits in the score to be displayed. Each of the following lines contains digits, each either or . These digits correspond to the segments of the respective digit's representation, listed from top to bottom, at the same level from left to right. Specifically, the first digit corresponds to the top segment, the second to the top left, the third to the top right, the fourth to the middle, the fifth to the bottom left, the sixth to the bottom right, and the seventh to the bottom segment. The value indicates the presence of a segment and its absence. The representation is given left to right, i.e., the first is the leftmost digit, the last is the rightmost.
Output a single number — the number of possible numbers that could have been displayed in the given way. Note that when displaying any digit, some segments may be omitted, but no digit should be displayed completely empty.
Example 1