Restoration of points quantity
Renowned hacker Vasya, upon discovering Petryk's intriguing game, decided to tamper with it a bit. He altered the subroutine responsible for displaying the player's score so that each line used in the digit's image could either appear on the screen or be omitted. As a result, players might not always be able to discern their exact score. For instance, the number **325** could be displayed as:
However, this same configuration could also represent the number **986**, among other possibilities. Your task is to determine how many different whole numbers could potentially be depicted in this manner.
Input
The first line contains the integer **K** (**1** ≤ **K** ≤ **9**) — the number of digits in the number that needs to be displayed. Each of the following **K** lines contains **7** digits, each either **0** or **1**. These digits correspond to the segments in the image of the respective digit, listed from top to bottom, and at the same level from left to right. Specifically, the first digit corresponds to the topmost 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 bottommost segment. A value of **1** indicates the presence of a segment, while **0** indicates its absence. The image is described from left to right, meaning the description of the leftmost digit in the number is given first, and the rightmost last.
Output
Output a single number on one line — the count of possible numbers that could have been depicted in the given manner. Note that when displaying any digit, some segments may be omitted, but no segment should be present in a position where it is not allowed in the correct display.