#include<bits/stdc++.h>
using namespace std;
const int maxn = 200090;
queue <int > q;
int f;
int vv[maxn];
int d[maxn];
int v[maxn];
int n,m,tot = 0,flag = 0,w;
int head[maxn];
struct node {
int fr,Next,ver,value;
};
node edge[maxn];
inline int Read () {
int xx = 0;
int ff = 1;
char ch = getchar();
while (ch > '9' || ch < '0') {
if (ch == '-') {
ff = -1;
}
ch = getchar();
}
while (ch <= '9' && ch >= '0') {
xx = (xx << 1) + (xx << 3) + ch - '0';
ch = getchar();
}
return xx * ff;
}
inline void add (int x,int y,int z) {
edge[++tot].fr = x;
edge[tot].Next = head[x];
edge[tot].ver = y;
edge[tot].value = z;
head[x] = tot;
}
inline void spfa() {
d[1] = 0;
v[1] = 0;
q.push(1);
while (!q.empty()) {
int x = q.front();
q.pop();
v[x] = 0;
for (int i = head[x];i;i = edge[i].Next) {
int y = edge[i].ver; int z = edge[i].value;
if (d[x] + z < d[y]) {
d[y] = d[x] + z;
vv[y]++;
if (vv[y] >= n) {
flag = 1;
return ;
}
if (v[y] != 1) q.push(y),v[y] = 1;
}
}
}
}
int main () {
f = Read();
while (f--) {
flag = 0;
memset(head,0,sizeof(head));
memset(v,0,sizeof(v));
memset(vv,0,sizeof(vv));
n = Read(); m = Read(); w = Read();
for (int i = 1;i <= n;i++) d[i] = 1e9;
for (int i = 1;i <= m;i++) {
int a = Read();
int b = Read();
int c = Read();
add (a,b,c); add (b,a,c);
}
for (int i = 1;i <= w;i++) {
int a = Read();
int b = Read();
int c = Read();
add(a,b,-c);
}
spfa();
if (flag == 1) printf("YES ");
else printf("NO ");
}
return 0;
}