This page is still under construction.

Parts of this page are still being built. What you see may change.

Skyland

Time limit5sMemory limit64 MB

Summary
Choose nonnegative island heights totaling at least H to minimize linear plus pairwise absolute-difference costs, and report each minimum as a reduced fraction.
Level

Hard8 of 10

Topics
Graph, Math
Solved
No attempts yet

Problem

Somewhere in the sky the KM kingdom built nn floating islands with its advanced technology. The islands are numbered from 11 to nn.

King Kitamasa picks the altitude of every island freely among the non-negative real numbers, as long as the altitudes add up to at least HH. Lifting island ii to altitude hih_i costs bihib_i h_i. The islands also talk to each other, so island ii and island jj cost another ci,j∣hi−hj∣c_{i,j} |h_i - h_j|.

Energy prices went up, so the king wants the total cost

∑i=1nbihi+∑1≤i<j≤nci,j∣hi−hj∣\sum_{i=1}^{n} b_i h_i + \sum_{1 \le i < j \le n} c_{i,j} |h_i - h_j|

to be as small as possible. You are the court programmer, so compute that minimum. It is always a rational number.

Input

The input holds several test cases. The first line of a test case has two integers nn and HH separated by one space (1≤n≤1001 \le n \le 100, 0≤H≤10000 \le H \le 1000). The second line has nn integers b1,b2,…,bnb_1, b_2, \dots, b_n (0≤bi≤10000 \le b_i \le 1000). Each of the next nn lines has nn integers ci,1,ci,2,…,ci,nc_{i,1}, c_{i,2}, \dots, c_{i,n} (0≤ci,j≤10000 \le c_{i,j} \le 1000). Always ci,i=0c_{i,i} = 0 and ci,j=cj,ic_{i,j} = c_{j,i}.

A line with two zeros follows the last test case. There are at most 2020 test cases.

Output

For each test case print one line in the form Case x: p/q. Here xx is the test case number counting from 11, and p/qp/q is the minimum total cost written as a reduced fraction, with q>0q > 0 and gcd⁡(p,q)=1\gcd(p, q) = 1. An integer minimum vv is printed as v/1. For example, a minimum of 22 is printed as 2/1 and a minimum of 17.517.5 is printed as 35/2.

Examples2

  1. Example 1

    Input
    2 1
    1 3
    0 1
    1 0
    3 3
    1 2 4
    0 2 0
    2 0 1
    0 1 0
    0 0
    
    Expected output
    Case 1: 2/1
    Case 2: 6/1
    
  2. Example 2

    Input
    2 5
    3 4
    0 1
    1 0
    0 0
    
    Expected output
    Case 1: 35/2