#include <iostream>
#include <vector>

using namespace std;

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

    vector<vector<int>> original_edges(n + 1, vector<int>(n + 1, 0));
    vector<vector<int>> modified_edges(n + 1, vector<int>(n + 1, 0));

    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        original_edges[u][v] = original_edges[v][u] = 1;
    }

    for (int i = 0; i < k; i++) {
        int u, v;
        cin >> u >> v;
        modified_edges[u][v] = modified_edges[v][u] = 1;
    }

    vector<vector<int>> actions;
    for (int a = 1; a <= n; a++) {
        for (int b = a + 1; b <= n; b++) {
            if (original_edges[a][b] != modified_edges[a][b]) {
                for (int c = 1; c <= n; c++) {
                    if (c != a && c != b) {
                        if ((original_edges[a][c] == 1 && original_edges[b][c] == 1) !=
                            (modified_edges[a][c] == 1 && modified_edges[b][c] == 1)) {
                            cout << "NO" << endl;
                            return 0;
                        }

                        if ((original_edges[a][c] == 1 && original_edges[b][c] == 1) &&
                            (modified_edges[a][c] == 0 || modified_edges[b][c] == 0)) {
                            actions.push_back({a, b, c});
                            modified_edges[a][c] = modified_edges[c][a] = 1;
                            modified_edges[b][c] = modified_edges[c][b] = 1;
                        } else if ((original_edges[a][c] == 0 && original_edges[b][c] == 0) &&
                                   (modified_edges[a][c] == 1 && modified_edges[b][c] == 1)) {
                            actions.push_back({a, b, c});
                            modified_edges[a][c] = modified_edges[c][a] = 0;
                            modified_edges[b][c] = modified_edges[c][b] = 0;
                        }
                    }
                }
            }
        }
    }

    cout << "YES" << endl;
    cout << actions.size() << endl;
    for (auto action : actions) {
        cout << action[0] << " " << action[1] << " " << action[2] << endl;
    }

    return 0;
}
