#include <iostream>
#include <cassert>
#include <queue>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <random>
#include <chrono>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define int long long
#define pii pair<int, int>
#define eb emplace_back
#define F first
#define S second
#define test(x) cout << "Test: " << (x) << '\n'
#define lowbit(x) (x & -x)
#define debug puts("qwq");
#define open(x) freopen(#x".in", "r", stdin);freopen(#x".out", "w", stdout);
#define close fclose(stdin);fclose(stdout);
namespace FastIO {
template <typename T = int>
inline T read() {
T s = 0, w = 1;
char c = getchar();
while (!isdigit(c)) {
if (c == '-') w = -1;
c = getchar();
}
while (isdigit(c)) s = (s << 1) + (s << 3) + (c ^ 48), c = getchar();
return s * w;
}
template <typename T>
inline void read(T &s) {
s = 0;
int w = 1;
char c = getchar();
while (!isdigit(c)) {
if (c == '-') w = -1;
c = getchar();
}
while (isdigit(c)) s = (s << 1) + (s << 3) + (c ^ 48), c = getchar();
s = s * w;
}
template <typename T, typename... Arp> inline void read(T &x, Arp &...arp) {
read(x), read(arp...);
}
template <typename T>
inline void write(T x, char ch = '\n') {
if (x < 0) x = -x, putchar('-');
static char stk[25];
int top = 0;
do {
stk[top++] = x % 10 + '0', x /= 10;
} while (x);
while (top) putchar(stk[--top]);
putchar(ch);
return;
}
template <typename T>
inline void smax(T &x, T y) {
if (x < y) x = y;
}
template <typename T>
inline void smin(T &x, T y) {
if (x > y) x = y;
}
void quit() {
exit(0);
}
} using namespace FastIO;
const int N = 220;
struct Matrix {
int a[N][N];
Matrix() {
for (int i=0;i<N;++i) for (int j=0;j<N;++j) a[i][j]=-1e18;
}
Matrix operator * (const Matrix x) {
Matrix ans;
for (int i=0;i<N;++i) for (int j=0;j<N;++j) for (int k=0;k<N;++k) smax(ans.a[i][j],a[i][k]+x.a[k][j]);
return ans;
}
} p[40];
struct Vector {
int a[N];
Vector() {
for (int i=0;i<N;++i) a[i]=-1e18;
}
Vector operator * (const Matrix x) {
Vector ans;
for (int i=0;i<N;++i) for (int j=0;j<N;++j) smax(ans.a[i],a[j]+x.a[j][i]);
return ans;
}
} res;
int a[N], n, m, T, k;
struct node {
int t, x, y;
bool operator < (const node x) {
return t < x.t;
}
} Q[N];
signed main() {
read(n, m, T, k);
for (int i=1;i<=n;++i) read(a[i]);
auto id=[&](int x,int y) { return (x-1)*n+y; };
for (int i=1;i<=n;++i) for (int j:{1,2,3,4}) p[0].a[id(j,i)][id(j+1,i)]=0;
for (int i=1;i<=m;++i) {
int u,v,w; read(u,v,w); p[0].a[id(w,v)][u]=a[v];
}
for (int i=1;i<=k;++i) read(Q[i].t,Q[i].x,Q[i].y);
sort(Q+1,Q+1+k);
Q[++k] = {T, 0, 0};
for (int i=1;i<=30;++i) p[i]=p[i-1]*p[i-1];
res.a[1]=a[1];
for (int i=1;i<=k;++i) {
int t=Q[i].t-Q[i-1].t;
for (int s=0;s<=30;++s) if (t>>s&1) res = res * p[s];
res.a[Q[i].x]+=Q[i].y;
} write(max(res.a[1],-1LL));
return 0;
}