n, m, k = map(int, input().split())
original_edges = [tuple(map(int, input().split())) for _ in range(m)]
target_edges = [tuple(map(int, input().split())) for _ in range(k)]

added_edges = []
deleted_edges = []

for edge in original_edges:
    if edge not in target_edges:
        for node in edge:
            for other_node in edge:
                if (node, other_node) not in original_edges and (node, other_node) not in added_edges:
                    added_edges.append((node, other_node, node))

for edge in target_edges:
    if edge not in original_edges:
        for node in edge:
            for other_node in edge:
                if (node, other_node) not in target_edges and (node, other_node) not in added_edges:
                    deleted_edges.append((node, other_node, other_node))

if len(added_edges) + len(deleted_edges) > 2 * 10**5:
    print("NO")
else:
    print("YES")
    print(len(added_edges) + len(deleted_edges))
    for edge in added_edges:
        print(edge[0], edge[1], edge[2])
    for edge in deleted_edges:
        print(edge[0], edge[1], edge[2])
