n, m, k = map(int, input().split())

# Создаем графы как списки смежности
graph1 = {i: [] for i in range(1, n + 1)}
graph2 = {i: [] for i in range(1, n + 1)}

# Считываем ребра первого графа
for _ in range(m):
    u, v = map(int, input().split())
    graph1[u].append(v)
    graph1[v].append(u)

# Считываем ребра второго графа
for _ in range(k):
    u, v = map(int, input().split())
    graph2[u].append(v)
    graph2[v].append(u)

# Проверяем, что графы идентичны
def are_graphs_identical(graph1, graph2):
    return all(sorted(graph1[i]) == sorted(graph2[i]) for i in range(1, n + 1))

if not are_graphs_identical(graph1, graph2):
    print("NO")
else:
    actions = []
    for u1 in range(1, n):
        for v1 in graph1[u1]:
            for u2 in range(u1 + 1, n + 1):
                if u2 not in graph1[u1]:
                    actions.append((u1, v1, u2))
    print("YES")
    print(len(actions))
    for action in actions:
        print(*action)
