def dfs(graph, visited, v):
    visited[v] = True
    for u in graph[v]:
        if not visited[u]:
            dfs(graph, visited, u)
            
def find_connected_components(graph, n):
    visited = [False] * (n + 1)
    components = 0
    for v in range(1, n + 1):
        if not visited[v]:
            dfs(graph, visited, v)
            components += 1
    return components

def isomorphism_check(graph1, graph2, n):
    visited = [False] * (n + 1)
    for v in range(1, n + 1):
        if len(graph1[v]) != len(graph2[v]):
            return False
        for u in graph1[v]:
            if u in graph2[v]:
                visited[v] = True
                visited[u] = True
    return all(visited)

def main():
    n, m, k = map(int, input().split())
    graph1 = [[] for _ in range(n + 1)]
    graph2 = [[] for _ in range(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)
    
    components1 = find_connected_components(graph1, n)
    components2 = find_connected_components(graph2, n)
    
    if components1 != components2:
        print("NO")
        return
    
    if isomorphism_check(graph1, graph2, n):
        print("YES")
        print(0)
        return
    
    t = []
    for v in range(1, n + 1):
        for u in graph1[v]:
            if u not in graph2[v]:
                for w in graph2[v]:
                    if w not in graph1[v]:
                        t.append((u, v, w))
                        graph1[u].remove(v)
                        graph1[v].remove(u)
                        graph1[v].append(w)
                        graph1[w].append(v)
    
    if len(t) > 2 * 10**5:
        print("NO")
        return
    
    print("YES")
    print(len(t))
    for operation in t:
        print(*operation)

if __name__ == "__main__":
    main()
