#include<stdio.h>
#include<string.h>
#include<stdbool.h>
#define N 510
#define M 5210
int f;
int n, m, w;
int s, e, t;
int dist[N];
int count[N];
int h[N], cnt;
int que[N], head, tail;
bool inQue[N];
struct edge{
int to;
int next;
int time;
}E[M];
void add(int v, int w, int time){
E[++cnt].next = h[v];
E[cnt].to = w;
E[cnt].time = time;
h[v] = cnt;
}
bool spfa(){
memset(dist, 0, sizeof dist);
memset(inQue, 0, sizeof inQue);
memset(count, 0, sizeof count);
head = 0, tail = 0;
for(int i = 1; i <= n; i++){
que[++tail] = i;
inQue[i] = true;
}
while(head != tail){
int t = que[++head];
head %= N;
inQue[t] = false;
for(int i = h[t]; i != -1; i = E[i].next){
int j = E[i].to;
if(dist[j] > dist[t] + E[i].time){
dist[j] = dist[t] + E[i].time;
count[j] = count[t] + 1;
if(count[j] >= n) return true;
if(!inQue[j]){
que[++tail] = j;
tail %= N;
inQue[j] = true;
}
}
}
}
return false;
}
int main(){
scanf("%d", &f);
while(f--){
scanf("%d %d %d", &n, &m, &w);
memset(h, -1, sizeof h);
cnt = 0;
for(int i = 1; i <= m; i++){
int a, b, t;
scanf("%d %d %d", &a, &b, &t);
add(a, b, t), add(b, a, t);
}
for(int i = 1; i <= w; i++){
int a, b, t;
scanf("%d %d %d", &a, &b, &t);
add(a, b, -t);
}
if(spfa()) printf("YES\n");
else printf("NO\n");
}
return 0;
}