This page is still under construction.

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

National Collegiate Programming Contest Club Federation

Time limit1sMemory limit128 MB

Summary
Given hotels with per-person prices and weekly capacities, find the cheapest hotel and week that fit all N members within budget B.
Level

Easy2 of 10

Topics
Brute force, Implementation
Solved
No attempts yet

Problem

Because you missed last year's meeting of the National Collegiate Programming Contest Club Federation (hereafter "the Federation"), you were elected as this year's president.

The president must hold one offline contest in the fall. You may freely choose which weekend to hold it, and you must pick a single hotel where all members will stay. The budget is tight, so you should choose as cheap a hotel as possible.

The rules are as follows:

  • Every member must stay at the same hotel on the same weekend. (Last year the members split across several hotels and some of them got lost.)
  • The chosen hotel must be able to accommodate all NN members during the chosen week.
  • The total cost of the trip may not exceed the budget BB. The total cost equals (number of participants) ×\times (the hotel's per-person price).

Among all valid options, find the smallest possible total cost.

Input

The first line contains the number of participants NN (1≤N≤2001 \le N \le 200), the budget BB (1≤B≤5000001 \le B \le 500000), the number of hotels HH (1≤H≤181 \le H \le 18), and the number of selectable weekends WW (1≤W≤131 \le W \le 13), separated by spaces.

Then the information for each hotel is given on two lines. The first line contains the per-person price pp (1≤p≤100001 \le p \le 10000). The second line contains, separated by spaces, the guest capacities for each week a1,a2,…,aWa_1, a_2, \dots, a_W (0≤ai≤10000 \le a_i \le 1000), where aia_i is the maximum number of people who can stay at that hotel during week ii.

Output

If the contest can be held, print the minimum total cost. If it cannot be held in any way, print stay home.

Examples2

  1. Example 1

    Input
    3 1000 2 3
    200
    0 2 2
    300
    27 3 20
    
    Expected output
    900
    
  2. Example 2

    Input
    5 2000 2 4
    300
    4 3 0 4
    450
    7 8 0 13
    
    Expected output
    stay home