#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main() {
    int n, m, k;
    cin >> n >> m >> k;

    set<pair<int, int>> originalEdges;
    set<pair<int, int>> modifiedEdges;

    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        originalEdges.insert({min(u, v), max(u, v)});
    }

    for (int i = 0; i < k; i++) {
        int u, v;
        cin >> u >> v;
        modifiedEdges.insert({min(u, v), max(u, v)});
    }

    vector<pair<int, int>> addedEdges, removedEdges;

    for (const auto& edge : modifiedEdges) {
        if (originalEdges.count(edge) == 0) {
            addedEdges.push_back(edge);
        }
    }

    for (const auto& edge : originalEdges) {
        if (modifiedEdges.count(edge) == 0) {
            removedEdges.push_back(edge);
        }
    }

    if (addedEdges.size() != removedEdges.size()) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
        cout << addedEdges.size() << endl;
        for (size_t i = 0; i < addedEdges.size(); i++) {
            cout << removedEdges[i].first << " " << addedEdges[i].first << " " << addedEdges[i].second << endl;
        }
    }

    return 0;
}
