#d11106. 历法
历法
Calendar
Problem Description
The calendar of country P is special: every year has months, and every month has days. Every week has days.
The first day of the year is also the first day of a week.
Find the number of pairs with such that day of month and day of month fall on the same weekday.
Input Format
The first line contains an integer , the number of test cases ().
The next lines each contain three integers ().
Output Format
Output lines, each containing a single integer: the number of valid pairs.
Sample Input
5
6 7 4
10 7 12
12 30 7
1 1 1
3247834 10298779 625324
Sample Output
6
9
5
0
116461800