#include <bits/stdc++.h>

using namespace std;

#define REP(i, n) for (int i=0; i<(n); ++i)
#define RREP(i, n) for (int i=(int)(n)-1; i>=0; --i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)
#define RFOR(i, a, n) for (int i=(int)(n)-1; i>=(a); --i)

#define SZ(x) ((int)(x).size())
#define all(x) begin(x),end(x)

#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair <T, U> &p) {
    return os << "(" << p.first << " " << p.second << ")";
}

template<class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld EPS = 1e-9;

template<class T>
struct edge {
    int src, to;
    T cost;

    edge() {}

    edge(int to, T cost) : src(-1), to(to), cost(cost) {}

    edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

    friend ostream &operator<<(ostream &os, const edge &e) {
        return os << "(" << e.src << "->" << e.to << ":" << e.cost << ")";
    }
};

template<class T>
vector<T> dijkstra(const vector<vector<edge<T>>>& g, int s) {
    const T INF = numeric_limits<T>::max();
    vector<T> d(g.size(), INF);

    using Pi = pair<T, int>;
    priority_queue<Pi, vector<Pi>, greater<Pi>> que;
    d[s] = 0;
    que.emplace(d[s], s);
    while (!que.empty()) {
        T cost; int v;
        tie(cost, v) = que.top();
        que.pop();
        if (d[v] < cost) continue;
        for (const auto &e : g[v]) {
            T nxt = cost + e.cost;
            if (d[e.to] > nxt) {
                d[e.to] = nxt;
                que.emplace(nxt, e.to);
            }
        }
    }
    return d;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    for (;;) {
        int N, M, H, K; cin >> N >> M >> H >> K;
        if (N == 0) break;

        struct line {
            int src, to, cost, time;
        };
        vector<vector<line>> lines(K);
        REP(i, M) {
            int a, b, c, h, r;
            cin >> a >> b >> c >> h >> r;
            --a, --b, --r;
            lines[r].push_back((line){ a, b, c, h });
            lines[r].push_back((line){ b, a, c, h });
        }

        int S, T; cin >> S >> T; --S, --T;
        int P; cin >> P;
        vi cover(P), price(P);
        REP(i, P) {
            int l; cin >> l >> price[i];
            REP(j, l) {
                int k; cin >> k; --k;
                cover[i] |= 1<<k;
            }
        }

        vvi dp(P+1, vi(1<<K, INF));
        dp[0][0] = 0;
        REP(i, P) REP(s, 1<<K) {
            if (dp[i][s] == INF) continue;
            chmin(dp[i+1][s | cover[i]], dp[i][s] + price[i]);
            chmin(dp[i+1][s], dp[i][s]);
        }

        int ans = INF;

        REP(s, 1<<K) {
            if (dp[P][s] == INF) continue;
            vector<vector<edge<int>>> G(N*(H+1));
            REP(i, K) {
                for (auto &l : lines[i]) {
                    for (int h = 0; h + l.time <= H; ++h) {
                        G[l.src * (H + 1) + h].emplace_back(l.to * (H + 1) + h + l.time,
                                s >> i & 1 ? 0 : l.cost);
                    }
                }
            }

            auto dist = dijkstra(G, S*(H+1));
            REP(h, H+1) {
                if (dist[T*(H+1) + h] >= INF) continue;
                chmin(ans, dist[T*(H+1) + h] + dp[P][s]);
            }
        }

        if (ans == INF) ans = -1;
        cout << ans << endl;
    }

    return 0;
}



Measured memory_bytes: 3816