New Calendar (Small)

Given months per year, days per month and days per week, count calendar rows when each month starts after the previous month and never shares a row.

Easy3SimulationMathInterviewNo attempts yetTime limit5sMemory limit512 MB

Problem

ELG8-G, a planet found outside the Solar System, has a rotation period and an orbital period that differ from Earth's, so Earth's calendar cannot be used there. Scientists decided to design a new calendar system for the planet. The Gregorian calendar used on Earth is awkward because the number of days changes from month to month, so in the new system every month has the same number of days.

The scientists want to print one large calendar to write a daily observation log on, and its size depends on how many months a year holds and how many days a week holds. Write a program that reads those numbers and prints the number of rows the calendar needs.

The calendar is laid out by these rules.

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

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 holds the number of test cases TT. Each of the next TT lines holds one test case as three positive integers MM, DD, WW.

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, where xx is the case number starting from 1 and yy is the number of rows the calendar needs.

Constraints

  • 1T1001 \le T \le 100
  • 1M201 \le M \le 20
  • 1D1001 \le D \le 100
  • 1W1001 \le W \le 100