#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <queue>

using namespace std;

const int INF = 1<<31-1;

int n, m, ww;
int d[55000];
int cnt;

struct node{
    int to;
    int next;//next
    int weight;
}e[60000];

int lastshow[40000], num[40000];
bool inqueue[40000];
queue<int>q;

void insert(int a, int b, int w){
    e[++cnt].to = b;
    e[cnt].weight = w;
    e[cnt].next = lastshow[a];
    lastshow[a] = cnt;//lastshownextlastshow
}

bool spfa(){
    q.push(1);
    num[1] ++;
    while(!q.empty()){
        int x = q.front();
        q.pop();
        inqueue[x] = false;
        int id = lastshow[x];
        while(id != -1){
            if(d[x] < INF && d[e[id].to] > e[id].weight + d[x]){
                d[e[id].to] = e[id].weight + d[x];
                if(!inqueue[e[id].to]){
                    inqueue[e[id].to] = true;
                    q.push(e[id].to);
                }
                num[id]++;
                if( num[id] > n )//
                    return true;
            }
            id = e[id].next;
        }
    }
    return false;
}

int main(){
    int f;
    int i;
    int a, b, w;
    cin >> f;
    while(f -- ){
        cnt = 0;
        scanf("%d %d %d", &n, &m, &ww);
        memset(lastshow,-1,sizeof(lastshow));
        memset(inqueue, false, sizeof(inqueue));
        memset(num, 0, sizeof(num));
        for(i = 1; i <= n; ++ i)
            d[i]=INF;
        d[1]=0;
        cnt=0;
        while(!q.empty())
        {
            q.pop();
        }
        for(i = 1; i <= m; i ++){
            scanf("%d %d %d", &a, &b, &w);
            insert(a, b, w);
            insert(b, a, w);
        }
        for(i = 1; i <= ww; i ++){
            scanf("%d %d %d", &a, &b, &w);
            insert(a, b, -w);
        }
        if(spfa())
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}