n, m, k = map(int, input().split())
graph1 = [[] for _ in range(n)]
graph2 = [[] 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)
for _ in range(k):
   u, v = map(int, input().split)
   graph2[u - 1].append(v - 1)
   graph2[v - 1].append(u - 1)
actions = []
for i in range(n):
   if len(graph1[i]) != len(graph2[i]):
       print("NO")
       exit()
print("YES")
deled = set()
for i in range(n):
   for v in graph2[i]:
       if v > i:
           deled.add((i, v))
for i in range(n):
   for j in graph1[i]:
       if (i, j) not in deled:
           actions.append((i + 1, j + 1, i + 1))
print(len(act))
for action in actions:
   print(action[0], action[1], action[2])