def check_isomorphism(graph1, graph2):
    # Реализуйте проверку изоморфизма графов
    pass

def find_actions(graph1, graph2):
    # Реализуйте поиск последовательности действий Паши
    pass

# Считываем входные данные
n, m, k = map(int, input().split())

graph1 = [[] for _ in range(n)]
for _ in range(m):
    u, v = map(int, input().split())
    graph1[u-1].append(v-1)
    graph1[v-1].append(u-1)

graph2 = [[] for _ in range(n)]
for _ in range(k):
    u, v = map(int, input().split())
    graph2[u-1].append(v-1)
    graph2[v-1].append(u-1)

# Проверяем условия задачи
if n != n or m != m or not check_isomorphism(graph1, graph2):
    print("NO")
else:
    actions = find_actions(graph1, graph2)
    print("YES")
    print(len(actions))
    for action in actions:
        print(*action)
