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)

if m > k or set(original_edges) != set(target_edges):
    print("NO")
else:
    diff_edges = [edge for edge in target_edges if edge not in original_edges]
    actions = []

    for edge in diff_edges:
        a, b = edge
        for i in range(1, n + 1):
            if (a, i) in original_edges and (b, i) in original_edges:
                actions.append((a, i, b))
                break

    print("YES")
    print(len(actions))
    for action in actions:
        print(action[0], action[1], action[2])
