#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <algorithm>
#define rep(i, l, r) for(int i = l; i <= r; i++)
#define down(i, l, r) for(int i = l; i >= r; i--)
#define MS 123
#define MAX 1037471823
using namespace std;
struct node
{
int x, y, z;
bool operator < (const node &k) const { return x < k.x; }
} c[1234];
int t, n, s, K, e, k[MS], vv, v[MS*2], d[MS], x, y, z, a, dp[MS][MS];
bool r[MS][MS], b[MS], bb[MS];
int main()
{
scanf("%d%d%d%d", &t, &n ,&K, &e);
rep(i, 1, e) scanf("%d%d%d", &c[i].x, &c[i].y, &c[i].z);
rep(i, 1, e) c[i+e].x = c[i].y, c[i+e].y = c[i].x, c[i+e].z = c[i].z; e *= 2;
sort(c+1, c+1+e); c[e+1].x = MAX;
k[1] = 1; rep(i, 2, n+1) { k[i] = k[i-1]; while (c[k[i]].x < i) k[i]++; }
scanf("%d", &a);
rep(i, 1, a)
{
scanf("%d%d%d", &z, &x, &y);
rep(i, x, y) r[z][i] = true;
}
rep(s, 1, t)
{
rep(i, 1, n) bb[i] = true;
rep(i, s, t)
{
rep(j, 1, n) if (r[j][i]) bb[j] = false;
v[1] = 1; vv = 1;
rep(j, 1, n) d[j] = MAX; d[1] = 0; b[1] = true;
while (vv > 0)
{
x = v[1];
rep(j, k[x], k[x+1]-1) if (bb[c[j].y] && d[c[j].y] > d[x] + c[j].z)
{
d[c[j].y] = d[x] + c[j].z;
if (b[c[j].y] == false) b[c[j].y] = true, v[++vv] = c[j].y;
}
v[1] = v[vv--]; b[x] = false;
}
if (d[n] == MAX) dp[s][i] = MAX; else dp[s][i] = d[n] * (i-s+1);
}
}
rep(i, 0, t-1) rep(j, 1, t-i) rep(o, j, j+i-1) if (dp[j][j+i] > dp[j][o] + dp[o+1][j+i] + K) dp[j][j+i] = dp[j][o] + dp[o+1][j+i] + K;
printf("%d\n", dp[1][t]);
return 0;
}
I2luY2x1ZGUgPGNtYXRoPgojaW5jbHVkZSA8Y3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ewogICAgICAgIHNjYW5mKCIlZCVkJWQiLCAmeiwgJngsICZ5KTsKICAgICAgICByZXAoaSwgeCwgeSkgclt6XVtpXSA9IHRydWU7CiAgICB9CiAgICByZXAocywgMSwgdCkgCiAgICB7CiAgICAgICAgcmVwKGksIDEsIG4pIGJiW2ldID0gdHJ1ZTsKICAgICAgICByZXAoaSwgcywgdCkgCiAgICAgICAgewogICAgICAgICAgICByZXAoaiwgMSwgbikgaWYgKHJbal1baV0pIGJiW2pdID0gZmFsc2U7CiAgICAgICAgICAgIHZbMV0gPSAxOyB2diA9IDE7CiAgICAgICAgICAgIHJlcChqLCAxLCBuKSBkW2pdID0gTUFYOyBkWzFdID0gMDsgYlsxXSA9IHRydWU7CiAgICAgICAgICAgIHdoaWxlICh2diA+IDApCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIHggPSB2WzFdOwogICAgICAgICAgICAgICAgcmVwKGosIGtbeF0sIGtbeCsxXS0xKSBpZiAoYmJbY1tqXS55XSAmJiBkW2Nbal0ueV0gPiBkW3hdICsgY1tqXS56KQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIGRbY1tqXS55XSA9IGRbeF0gKyBjW2pdLno7CiAgICAgICAgICAgICAgICAgICAgaWYgKGJbY1tqXS55XSA9PSBmYWxzZSkgYltjW2pdLnldID0gdHJ1ZSwgdlsrK3Z2XSA9IGNbal0ueTsgCiAgICAgICAgICAgICAgICB9IAogICAgICAgICAgICAgICAgdlsxXSA9IHZbdnYtLV07IGJbeF0gPSBmYWxzZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBpZiAoZFtuXSA9PSBNQVgpIGRwW3NdW2ldID0gTUFYOyBlbHNlIGRwW3NdW2ldID0gZFtuXSAqIChpLXMrMSk7CiAgICAgICAgfQogICAgfQogICAgcmVwKGksIDAsIHQtMSkgcmVwKGosIDEsIHQtaSkgcmVwKG8sIGosIGoraS0xKSBpZiAoZHBbal1baitpXSA+IGRwW2pdW29dICsgZHBbbysxXVtqK2ldICsgSykgZHBbal1baitpXSA9IGRwW2pdW29dICsgZHBbbysxXVtqK2ldICsgSzsKICAgIHByaW50ZigiJWRcbiIsIGRwWzFdW3RdKTsKICAgIHJldHVybiAwOwp9