|Author:||A. Klenin||Time limit:||1 sec|
|Input file:||input.txt||Memory limit:||256 Mb|
Human spaceship has discovered an abandoned alien vessel in the interstellar space. Aboard the vessel, various recordings were found and xeno-archeologists have started to decipher them.
First, they were able to recognize numerals and convert them to the human notation. The next step is converting dates.
Alien dates are apparently measured in 4 units (as opposed to 3 human units — years, months and days). Also, unlike the human one, alien calendar is regular — for each unit, its ratio to the next one is whole and fixed. The problem is to find those ratios.
One of records seemed to be an astronomical log, describing and dating various notable cosmic events. Scientists were able to identify some of the events, and determine the corresponding dates. Surprisingly, the smallest unit of the alien calendar happened to be exactly equal to one Earth day.
Your program must, given the list of alien and corresponding human dates, determine all possible sets of unit ratios for the alien calendar.
All human dates are correct. You may assume that the ratios are in the range from 2 to 100.
The human calendar have 12 months, containing 31, 28 or 29, 31, 30, 31, 30, 31, 31, 30, 31, 30 and 31 days. The second month has 29 days if the year is either divisible by 400 or divisible by 4 and not divisible by 100.
Input file contains an integer N — the number of dates, followed by N groups of 7 numbers each: ui vu wi ti di mi yi. In the group, ui vu wi ti are numbers comprising i-th alien date, in order from the smallest to the largest unit, di mi yi are day, month and year of the same date in the human calendar.
Output file must contain an integer M — number of possible calendars.
1 ≤ N ≤ 10;
1 ≤ ui, vi, wi ≤ 100;
1 ≤ ti ≤ 10000;
1 ≤ di ≤ 31;
1 ≤ mi ≤ 12;
1600 ≤ yi < 10000;
|No.||Input file (
||Output file (|