Izua University Elementary School is famous as one of Japan's leading competition programmer training schools. The teachers at this school have a wide range of algorithmic knowledge and utilize it on a daily basis. As a teacher, you will be in charge of drawing and crafting classes this year. In this class, all children are supposed to complete one task in one year. The outline of the class is as follows.

* There are D lessons in a year (no lessons more than once on the same day), all of which are devoted to assignment production.
* There are M types of assignments to create.
* Assign one task from M types to each child.
* There are N children, and each of them is assigned a different task.



Children use several of the K types of parts to complete the task. The outline of the assignment production is as follows.

* The type and number of parts to be used are predetermined for each task.
* The type and number of parts used to complete the task must match the type and number of parts used in the task in just proportion.
* For different tasks, the types and numbers of parts used may all be the same.
* For each task, only two parts of the same type can be used.
* The order in which the parts are used does not affect the completion of the task.
* P bags containing some parts are prepared in advance. However, different bags may contain the same type and number of parts.
* Teachers can only give one bag per child (some children may not give it).
* The same bag cannot be given to two or more children (on the contrary, some bags may not be given to anyone).
* The child who is given the bag must use all the parts contained in the bag for the tasks he / she creates.



Parts used for the assignment other than the parts in the bag must be purchased separately. The conditions for purchasing parts are as follows.

* Parts can only be purchased on class days and can only be used on that day.
* Up to L parts can be purchased in one lesson for each task.
* Prices are set according to the type of parts, and the price fluctuates depending on the date of purchase. However, none of them will be out of stock.



Under these conditions, you want to keep your lesson costs as low as possible. Therefore, I decided to create a program to calculate the minimum total cost of purchasing parts for all children.



input

The input consists of multiple datasets. The end of the input is indicated by three zero lines. Each dataset is given in the following format:


D K L
c1,1 c1,2 ... c1, K
c2,1 c2,2 ... c2, K
::
cD, 1 cD, 2 ... cD, K
M N P
r1,1 r1,2 ... r1, K
r2,1 r2,2 ... r2, K
::
rM, 1 rM, 2 ... rM, K
t1,1 t1,2 ... t1, K
t2,1 t2,2 ... t2, K
::
tP, 1 tP, 2 ... tP, K


The numbers given on each line are separated by a single space.

D (1 ≤ D ≤ 8) indicates the number of lessons, K (1 ≤ K ≤ 8) indicates the number of parts types, and L (1 ≤ L ≤ 8) indicates the number of parts that can be purchased per day. .. cd, k (1 ≤ cd, k ≤ 100) indicates the price of part k on day d.

M (1 ≤ M ≤ 200) indicates the number of task types, N (1 ≤ N ≤ M) indicates the number of students, and P (1 ≤ P ≤ 200) indicates the number of bags.

rm, k (0 ≤ rm, k ≤ 2) indicates the number of parts k required for task m, and tp, k (0 ≤ tp, k ≤ 2) indicates the number of parts k contained in the bag p.

Tasks that do not require any parts or empty bags shall not be given.

The number of datasets does not exceed 20.

output

For each data set, output the minimum value of the total parts purchase cost for all students on one line. If N kinds of works cannot be completed, -1 is output.

Example

Input

2 2 1
5 3
2 2
3 3 1
2 0
1 2
2 2
1 1
2 2 1
5 3
2 2
3 2 1
2 0
1 2
2 2
1 1
2 2 2
5 3
2 2
3 2 1
2 0
1 2
2 2
1 1
4 3 1
2 2 1
3 2 2
2 3 3
1 2 2
5 4 3
1 1 0
1 0 1
1 0 2
1 1 2
2 2 2
1 0 1
2 0 2
1 1 1
0 0 0


Output

-1
9
6
7
// ???????????????
#include<vector>
#include<map>
#include<queue>
#include<tuple>
#include<functional>
// ?????????
  const int NIL = -1;
  const double INF = 1e9;
class MinimumCostFlow {
private:
  struct Edge {
    int from, to;
    double weight, capacity;
    Edge() {}
    Edge(int f, int t, double w, double c) : from(f), to(t), weight(w), capacity(c) {}
    bool operator<(const Edge& e) const {return from < e.from;}
  };
public:
  void insert(int f, int t, double w, double c);
  double PrimalDual(int source, int sink, int n) const;
private:
  std::map<int, std::vector<Edge>> edge_;
};
// ????????????
void MinimumCostFlow::insert(int f, int t, double w, double c) {
  edge_[f].emplace_back(f, t, w, c);
  edge_[t].emplace_back(t, f, -w, 0);
}
// ????°??????¨??? O(????????? * (E + V log V))
double MinimumCostFlow::PrimalDual(int source, int sink, int n) const {
  std::map<int, std::map<int, double>> flow;
  std::map<int, double> distance;
  double result = 0;
  while(true) {
    // source ?????? Dijkstra
    std::map<int, double> difference;
    std::map<int, Edge> via;
    typedef std::tuple<double, Edge> Node;
    std::priority_queue<Node, std::vector<Node>, std::greater<Node>> q;
    q.emplace(0, Edge(source, source, 0, 0));
    while(!q.empty()) {
      double dif;
      Edge edge;
      std::tie(dif, edge) = q.top();
      q.pop();
      int prev = edge.from;
      int current = edge.to;
      if(difference.count(current)) continue;
      difference[current] = dif;
      via[current] = edge;
      if(edge_.count(current)) for(const auto& e: edge_.at(current)) {
        double residue = e.capacity - flow[e.from][e.to];
        double d = e.weight + distance[e.from] - distance[e.to];
        if(residue > 0) q.emplace(dif + d, e);
      }
    }
    // ???????????¢?????´??°
    for(auto d: difference) distance[d.first] += d.second;
    // sink ?????§?????????????????¨??????????????°??????
    if(!via.count(sink)) break;
    // ?????????????????????????????????
    double add = INF;
    for(int v = sink; v != via[v].from; v = via[v].from) add = std::min(add, via[v].capacity - flow[via[v].from][via[v].to]);
    for(int v = sink; v != via[v].from; v = via[v].from) {
      flow[via[v].from][via[v].to] += add;
      flow[via[v].to][via[v].from] -= add;
      result += add * via[v].weight;
    }
    n -= add;
    if(n == 0) return result;
  }
  return -1;
}

#include<bits/stdc++.h>
using namespace std;

vector<int> memo(9);
int pow3(int n) {return memo[n] ? memo[n] : (memo[n] = (n < 1 ? 1 : 3 * pow3(n - 1)));}

int main() {
  int D, K, L;
  while(cin >> D >> K >> L, D | K | L) {
    vector<vector<int>> c(D, vector<int>(K));
    for(auto& i: c) for(auto& j: i) cin >> j;
    int M, N, P;
    cin >> M >> N >> P;
    vector<vector<int>> r(M, vector<int>(K));
    for(auto& i: r) for(auto& j: i) cin >> j;
    vector<vector<int>> t(P, vector<int>(K));
    for(auto& i: t) for(auto& j: i) cin >> j;

    const int INF = 1e9;
    vector<vector<vector<int>>> dp(D + 1, vector<vector<int>>(pow3(K), vector<int>(L + 1, INF)));
    dp[0][0][0] = 0;
    for(int day = 0; day < D; ++day) for(int ternary = 0; ternary < pow3(K); ++ternary) for(int bought = 0; bought <= L; ++bought) {
      dp[day + 1][ternary][0] = min(dp[day + 1][ternary][0], dp[day][ternary][bought]);
      if(bought == L) continue;
      for(int part = 0; part < K; ++part) {
        int owned = (ternary / pow3(part)) % 3;
        if(2 <= owned) continue;
        dp[day][ternary + pow3(part)][bought + 1] = min(dp[day][ternary + pow3(part)][bought + 1], dp[day][ternary][bought] + c[day][part]);
      }
    }

//     for(int ternary = 0; ternary < pow3(K); ++ternary) for(int bought = 0; bought <= L; ++bought) {
//       for(int i = 0; i < K; ++i) cout<<((ternary / pow3(i)) % 3);
//       cout<<": "<<dp[2][ternary][bought]<<endl;
//     }

    MinimumCostFlow graph;
    int no_bag = P + M;
    int source = P + M + 1;
    int sink = P + M + 2;
    graph.insert(source, no_bag, 0, INF);
    for(int i = 0; i < P; ++i) graph.insert(source, i, 0, 1);
    for(int j = 0; j < M; ++j) graph.insert(P + j, sink, 0, 1);
    for(int j = 0; j < M; ++j) {
      int need = 0;
      for(int part = 0; part < K; ++part) need += pow3(part) * r[j][part];
      if(dp[D][need][0] != INF) graph.insert(no_bag, P + j, dp[D][need][0], 1);
      for(int i = 0; i < P; ++i) {
        int remain = need;
        for(int part = 0; part < K; ++part) {
          if(r[j][part] - t[i][part] < 0) {remain = -1; break;}
          remain -= pow3(part) * t[i][part];
        }
        if(~remain) if(dp[D][remain][0] != INF) graph.insert(i, P + j, dp[D][remain][0], 1);
      }
    }

    cout << graph.PrimalDual(source, sink, N) << endl;
  }
}