#include <bits/stdc++.h>

#define int long long
#define pii pair<long long, long long>

using namespace std;

vector<set<int>> g;

void flip(int x, int y) {
    if (find(g[x].begin(), g[x].end(), y) != g[x].end()) {
        g[x].erase(y);
        g[y].erase(x);
    } else {
        g[x].insert(y);
        g[y].insert(x);
    }
}

signed main() {
    cin.tie(0); ios_base::sync_with_stdio(0);
    
    int n, m, m2;
    cin >> n >> m >> m2;
    vector<set<int>> g2(n);
    g.resize(n);
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        g[x].insert(y);
        g[y].insert(x);
    }
    for (int i = 0; i < m2; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        g2[x].insert(y);
        g2[y].insert(x);
    }

    for (int i = 0; i < n; i++) {
        if (g[i].size() % 2 != g2[i].size() % 2) {
            cout << "NO\n";
            return 0;
        }
    }

    vector<tuple<int, int, int>> ans = {};
    for (int i = 0; i < n; i++) {
        set<int> flp = {};
        for (int j : g[i]) {
            if (find(g2[i].begin(), g2[i].end(), j) == g2[i].end()) {
                flp.insert(j);
            }
        }
        for (int j : g2[i]) {
            if (find(g[i].begin(), g[i].end(), j) == g[i].end()) {
                flp.insert(j);
            }
        }
        /*cout << i << ": ";
        for (int f : flp) cout << f << " ";
        cout << "\n";*/
        int fp = -1;
        for (int f : flp) {
            if (fp == -1) {
                fp = f;
                continue;
            }
            flip(f, fp);
            flip(i, fp);
            flip(i, f);
            ans.push_back({i + 1, f + 1, fp + 1});
        }
    }

    cout << "YES\n" << ans.size() << "\n";
    for (auto [x, y, z] : ans) {
        cout << x << " " << y << " " << z << "\n";
    }
}