This page is still under construction.

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

Cleaning Stations

Interview

Time limit2sMemory limit512 MB

Summary
Given weights and a feature matrix, print the indices of the rows whose weighted sum is largest, in ascending order, for each of K data sets.
Level

Easy2 of 10

Topics
Implementation, Array, Math
Solved
No attempts yet

Problem

One of the symbiotic relationships among marine animals is the cleaning station. A cleaning station is a place such as a sea mount where cleaner fish gather in large numbers. A large fish such as a shark swims up to a cleaning station and picks out cleaner fish to take the parasites off its skin. The cleaner fish get a meal and the shark gets cleaned. Both profit.

A shark is defenseless while it is being cleaned, so it is very picky about which fish it lets near. If anything seems off, it leaves at once. The caution is earned. Some cleaner fish take small bites out of the shark along with the parasites.

A shark judges a cleaner fish by several features, and it assigns every feature a weight that is either positive or negative. One shark may prefer a larger cleaner fish, want a shorter distance to swim, and want the cleaner fish to move slowly. Given the feature values of every cleaner fish, find all the cleaner fish whose weighted sum of feature values is the largest.

Input

The first line contains the number KK of data sets. KK data sets follow, each in the format below.

The first line of a data set contains two integers nn and mm. nn is the number of cleaner fish, with 1≤n≤1001 \le n \le 100, and mm is the number of features the shark judges by, with 1≤m≤101 \le m \le 10.

The next line contains mm integers x1,x2,…,xmx_1, x_2, \dots, x_m, the weights the shark assigns to the mm features. Every weight is between −20-20 and 2020.

Then come nn lines, one per cleaner fish. The ii-th of those lines contains mm integers yi,1,yi,2,…,yi,my_{i,1}, y_{i,2}, \dots, y_{i,m}, the feature values of cleaner fish ii. Every yi,jy_{i,j} is an integer between −20-20 and 2020.

Output

For each data set, first print Data Set x: on a line of its own, where xx is the number of the data set counting from 11.

Then print, in ascending order and one per line, the numbers of all cleaner fish whose weighted sum ∑j=1mxjyi,j\sum_{j=1}^{m} x_j y_{i,j} is the largest. Cleaner fish are numbered 11 through nn in input order.

Print one blank line after the output of each data set.

Examples2

  1. Example 1

    Input
    2
    3 2
    1 -1
    2 1
    -1 -5
    4 2
    3 4
    0 3 -1 1
    20 1 -1 2
    -20 -1 1 10
    5 2 0 0
    
    Expected output
    Data Set 1:
    2
    
    Data Set 2:
    1
    2
    3
    
  2. Example 2

    Input
    1
    6 2
    2 -1
    0 0
    5 3
    1 -5
    3 -1
    5 3
    -2 4
    
    Expected output
    Data Set 1:
    2
    3
    4
    5