#include <iostream>
#include <algorithm>
#include <vector>
#define f first
#define s second

using namespace std;

int main()
{
    int n, m, k; cin >> n >> m >> k;
    vector <pair<int, int>> a, b;
    bool p[n], q[n];
    fill(p, p+n, false);
    fill(q, q+n, false);
    for (int i=0; i<m; i++)
    {
        int ip, in; cin >> ip >> in;
        if (ip==1)
            p[in-1]=true;
        else if (in==1)
            p[ip-1]=true;
        else
        a.push_back({ip-1, in-1});
    }
    for (int i=0; i<k; i++)
    {
        int ip, in; cin >> ip >> in;
        if (ip==1)
            q[in-1]=true;
        else if (in==1)
            q[ip-1]=true;
        else
        b.push_back({ip-1, in-1});
    }

    vector <pair<int, int>> ans;
    for (auto c:a)
    {
        ans.push_back(c);
        p[c.f]=!p[c.f];
        p[c.s]=!p[c.s];
    }
    for (auto c:b)
    {
        ans.push_back(c);
        p[c.f]=!p[c.f];
        p[c.s]=!p[c.s];
    }
    /*
    for (bool c:p)
        cerr << c;
    for (bool c:q)
        cerr << c;
        */
    for (int i=1; i<n; i++)
        if (p[i]!=q[i])
        {cout << "NO"; return 0;}
    {
        cout << "YES" << endl;
        cout << ans.size() << endl;
        for (auto c:ans)
            cout << 1 << ' ' << c.f+1 << ' ' << c.s+1 << endl;
    }
    return 0;
}
