New Calendar (Large)

From the counts of months, days per month, and days per week, compute the number of rows the year calendar occupies under the layout rules.

Medium5MathSimulationNo attempts yetTime limit5sMemory limit512 MB

Problem

The newly found planet ELG8-G outside the solar system rotates and orbits on a different schedule from Earth, so Earth's calendar does not fit it. Scientists decided to build a new calendar system for the planet. The Gregorian calendar used on Earth is awkward because the number of days differs from month to month, so in the new system every month has the same number of days.

The scientists want to print a large calendar for writing down daily observations. The size of that calendar depends on how many months make up a year and how many days make up a week. Write a program that reads those numbers and prints how many rows the calendar needs.

The calendar is printed by these rules.

  • The first day of the first month goes in the first column.
  • For every month after the first, the first day goes in the column right after the column of the previous month's last day.
  • Days that belong to different months never share a row.
  • The calendar covers exactly one year.

With 11 days in a month, 3 months in a year, and 4 days in a week, the calendar takes 11 rows.

#0#1#2#3
1234
5678
91011
1
2345
6789
1011
12
3456
78910
11

Input

The first line contains the number of test cases TT. Each of the next TT lines holds one test case as three natural numbers separated by spaces.

M D W

MM is the number of months in a year, DD is the number of days in a month, and WW is the number of days in a week.

Output

For each test case, print one line in the form Case #x: y. Here xx is the case number starting from 1, and yy is the number of rows the calendar needs.

Constraints

  • 1T1001 \le T \le 100
  • 1M10121 \le M \le 10^{12}
  • 1D1061 \le D \le 10^{6}
  • 1W1001 \le W \le 100